Repository navigation
fix(runtime): leak probe review fixes - #591
Conversation
- Settle before every snapshot: findLeakCycles and the cycles, strict and inspect triggers run three full collections, each followed by the queued releases and a synchronous drain of deallocated canary records. A wrapper that dies in the snapshot's own collection reports its queued retains (Instance.queued), so its object is neither listed as changed nor stripped of its root status, and the pending retain counts as the runtime's. - Model the object a resurrecting wrapper lives for: an ns:kept edge from the object to a GC-protected wrapper behind a weak handle, excluded from the two-node loop check like ns:owned. - The state handles of canary records whose object is being or was deallocated are the runtime's handles, not roots. - Scope the handles EdgeName and NodeName make. - LeakProbe SPI version 3. - Docs: settling, ns:kept, and the JS block disposal race as a limitation.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes in the leak probe (#576). These are issues the Android port's review found (NativeScript/android#2130), checked against the iOS code. Each new spec fails without its fix.
Fixes
findLeakCycles()and the cycles and strict Darwin triggers took the snapshot right away; only the counts and inspect triggers settled.canarymode: a canary that died in the snapshot's own GC has its handle reset while itsInstancesentry and the runtime's queued +1 remain. Its object was listed aschangedand lost its root status, so cycles through an outside-owned object came backuncertainwith the wrong reason. Inrootedmode the queued +1 read as an outside owner and hid cycles.-deallocs; the docs say so.Instance.queuedfield gives the count of retains still queued for dead wrappers, per object. A queued seed is not marked changed, and its pending retains count as the runtime's.ns:keptedge. Inresurrectingmode, a TS/@NativeClass-extended wrapper that native code retains is GC-protected but sits behind a weak handle. The graph had no edge from its object to it, so cycles through the wrapper's JS were reported while the object was owned from outside. The object now has anns:keptedge to the wrapper, excluded from the two-node loop check likens:owned.EdgeNameandNodeNameopen their ownHandleScope, so the walk no longer accumulates a handle per edge.LeakProbeSPI.hgoes to version 3, for the newInstance.queuedfield and host visitor.Not affected on iOS, unlike Android: the "(Global handles)" edge filter, the
ClearObjectIdsguard (iOS checks whether the context already had an id), the ephemeron edge prefix, and truncation.A JS block whose
kBlockDeallocatingbit is set while it waits for the runtime's lock still reads as a root. That is documented as a limitation.Specs (
WrapperLifetimeLeaksTests.js)canaryonly: an object whose canary just died, probed right after__collect()with no settle, is notchangedand has no cycle reported.canaryonly: a cycle shared with an owner released in the same turn is still found.__extends) held by an owner the probe can't see, with a JS ↔ block cycle through its wrapper, is not reported.Testing
2161 specs, 0 failures in
resurrecting/extended,rooted/all,canary/all,canary/extended, andcanary/allunder ASan. Specs (1) and (3) failed on main under canary; spec (2) failed on main in default mode.Summary by CodeRabbit
Bug Fixes
Documentation