The vars list contains a reference to itself, which counts as a ref to the initiating datum.
This makes code that seeks to copy over a datum's vars hold a hard reference to that datum in a very unclear way
Numbered Steps to Reproduce Problem:
Make a global list
Inside a proc, create a datum, insert its vars list into the global list
Exit proc
Code Snippet (if applicable) to Reproduce Problem:
// Holds a text ref to the creating datum, lets us know if it's been GC'd yet
var/static/ref
// Holds the contents of the creating datum's vars list
var/static/list/stuff = list()
/proc/copy_vars()
var/datum/bill = new()
stuff += bill.vars
ref = "\ref[bill]"
/proc/main()
test()
// Check to see if jim has been gc'd (if no refs remain it should)
var/datum/jim = locate(ref)
if(jim)
world.log << refcount(jim)
Expected Results:
Nothing. bill/jim GCs since no refs remain
Actual Results:
bill/jim live on, because stuff holds an entry formatted like this
list["vars"] = datum.vars
which hangs a ref to the datum
Does the problem occur:
Every time? Or how often? yes
In other games? yes
In other user accounts? yes
On other computers? yes
When does the problem NOT occur?
If the vars entry is removed from the list
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Yes. Last properly working version was 515.1610
Workarounds:
IDK cut the vars list from the inserted vars list I guess