Repository navigation
Conversation
When an object that is a key of several WeakMaps is freed, zend_weakrefs_notify() released the value of each map in turn. Releasing a value can run arbitrary code while the object is still a key of the maps not processed yet: - The GC (from a destructor, or the root buffer filling up). The object has IS_OBJ_FREE_CALLED, so the GC does not scan it. gc_scan_black() defers marking those entries black to the key when the key is grey, and the key never does it, so the entries keep the refcount that gc_mark_grey() removed. The value is later released once too often. - A destructor iterating one of those maps, which hands the object being freed back to userland. Remove the object from every map before releasing any of the values.
057c606 to
eddef20
Compare
|
This is yet another instance of #20001. |
|
Independently reproduced this against current Ran the regression test from this branch ( Plain, non-instrumented build — no tooling needed to see something is wrong: vs. the expected clean AddressSanitizer build ( The read is exactly 0 bytes past the end of the GC's own root buffer (allocated by Given this is: core engine (no extension), no non-default |
AI disclosure: I used an LLM (Claude) to investigate, fix and test this bug, and to write this description. Per CONTRIBUTING.md, everything below this line is LLM-written and is quoted.