lisdude / toaststunt

A network accessible, multi-user, programmable, interactive system for the creation of LambdaMOO style MOOs / MUDs.
63 stars 27 forks source link

Free waif self-reference on task_free #74

Closed StraylightRunMOO closed 1 year ago

StraylightRunMOO commented 1 year ago

The following code will create a hanging reference:

$waif::spawn_task   this none this
{?wait = 1} = args;
fork task_id (wait)
    player:tell("I'M A WAIF!");
endfork
kill_task(task_id);

The reference persists until shutdown:

;waif_stats()
=> ["pending_recycle" -> 0, "total" -> 0]
;$waif:new():spawn_task()
=> 0
;waif_stats()
=> [#118 -> 1, "pending_recycle" -> 0, "total" -> 1]

On shutdown, you will see the warning: WARN: waif_count != n_saved_waifs!

This commit addresses the issue by freeing the reference created here in tasks.cc:1273.

tvdijen commented 1 year ago

Nice catch!

sevenecks commented 1 year ago

Nice job.