bind: make Seq.RefTracker.createRef obey the refcnt invariant

An inspection of the RefTracker inc and dec methods suggests
that a particular Java Stub instance is included in the javaObjs
map if and only if its reference count, refcnt, is larger than zero.

A newly created reference created by RefTracker.createRef has zero
refcnt but was also inserted in the javaObjs map, violating the invariant.

Fix that by not inserting new references in javaObjs. Without the fix
a Stub instance that were never passed to Go would leak, along with
any other instances it referenced, transitively.

This fixes a Java reference tracking problem, I have not verified if
the same problem applies to the Go and ObjC sides of the Seq machinery.

Change-Id: I3ede90d5258630bc837fe61bba850df222d09a26
Reviewed-on: https://go-review.googlesource.com/19261
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur
2016-02-05 12:55:00 +00:00
committed by Hyang-Ah Hana Kim
parent 002f07f8be
commit 89fdf89e93
-1
View File
@@ -282,7 +282,6 @@ public class Seq {
}
int refnum = next++;
Ref ref = new Ref(refnum, o);
javaObjs.put(refnum, ref);
return ref;
}