OK, that all makes sense to me, but if I've missed an add_ref() in my code, shouldn't that cause the object to be freed or destructed prematurely? I added an add_ref(o) to my code to prevent this problem, but the result was that the objects weren't getting freed. I've stepped through a simple program that exhibits the problem, and that object comes to schedule_really_free_object() numerous times, each time with a refcount of 0 or -1. I've noticed that once it finally enters its endless loop, o->next == o... shouldn't that cause the loop to stop?
Please check if o->prog is still set the second time. If it is, and the object is on the top of the objects_to_destruct queue, the queue will become circular, and when the destruct pass comes it will loop forever.
Bill