In the pathological case shown in
https://github.com/quickjs-ng/quickjs/issues/367 both the object and the registry will be destroyed as part of the GC phase of JS_FreeRuntime. When the GC sweep happens it's possible we are holding on to a corpse so avoid calling the registry callback in that case.
This is similar to how Weak{Map,Set} deal with iterators being freed as part of a cycle.
In the pathological case shown in https://github.com/quickjs-ng/quickjs/issues/367 both the object and the registry will be destroyed as part of the GC phase of JS_FreeRuntime. When the GC sweep happens it's possible we are holding on to a corpse so avoid calling the registry callback in that case.
This is similar to how Weak{Map,Set} deal with iterators being freed as part of a cycle.
Fixes: https://github.com/quickjs-ng/quickjs/issues/367