From 89fdf89e9365abb9e5b7128ff4ff2458400ecba4 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 5 Feb 2016 13:05:27 +0100 Subject: [PATCH] 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 --- bind/java/Seq.java | 1 - 1 file changed, 1 deletion(-) diff --git a/bind/java/Seq.java b/bind/java/Seq.java index 7136263..b7cfa6b 100644 --- a/bind/java/Seq.java +++ b/bind/java/Seq.java @@ -282,7 +282,6 @@ public class Seq { } int refnum = next++; Ref ref = new Ref(refnum, o); - javaObjs.put(refnum, ref); return ref; }