Skip to content

Commit 2364814

Browse files
committed
fix(runtime): leak probe reads a canary record's weak-collection key
1 parent cb0c82d commit 2364814

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎docs/ns-builtin-modules.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ from a V8 heap snapshot (its roots minus the runtime's handles to canary
271271
records), the Java heap from an HPROF dump (`android.os.Debug.dumpHprofData`;
272272
its GC roots minus the runtime's object table, `Reference` referents skipped),
273273
and the runtime's own edges between them (a live wrapper holds its Java object;
274-
a Java object holds its canary record: state, prototype and implementation
275-
object; a Java object held weakly for a resurrected wrapper holds that wrapper). A `WeakMap` value is followed from its key only. A Java object the
274+
a Java object holds its canary record: state, weak-collection key, prototype
275+
and implementation object; a Java object held weakly for a resurrected wrapper holds that wrapper). A `WeakMap` value is followed from its key only. A Java object the
276276
runtime holds for a live wrapper, and that nothing else reaches, is leaked. For each, the report gives the path from the Java
277277
object to its own wrapper through fields, properties and the runtime's edges,
278278
a `signature` (the path's node labels from their smallest rotation, free of

‎test-app/app/src/main/assets/app/tests/testWrapperLifetimeLeaks.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe("Wrapper lifetime leak probe", function () {
6464
planted.push(new WeakRef(held));
6565

6666
// A WeakMap value referencing its own key: in canary mode the key is the
67-
// object's lifetime key, which its state holds.
67+
// object's lifetime key, which its record holds.
6868
var mapped = new java.lang.Runnable({ run: function () {} });
6969
probeMap.set(mapped, { probeMapped: mapped });
7070
planted.push(new WeakRef(mapped));

‎test-app/runtime/src/main/cpp/ObjectManager.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,9 @@ std::vector<ObjectManager::LeakProbeEntry> ObjectManager::GetLeakProbeEntries()
14101410
if (!record->state.IsEmpty()) {
14111411
entry.recordValues.push_back(record->state.Get(isolate));
14121412
}
1413+
if (!record->key.IsEmpty()) {
1414+
entry.recordValues.push_back(record->key.Get(isolate));
1415+
}
14131416
}
14141417
return entries;
14151418
}

0 commit comments

Comments
 (0)