On 09/29/17 22:34, mandy chung wrote:
On 9/27/17 2:31 AM, Peter Levart wrote:
Up to a point where 'this' is dereferenced to obtain the 'zsRef'
value (line 261), the Deflater instance is reachable. But after that,
even ensureOpen() may be inlined and 'this' is not needed any more.
After that point, obtaining zsRef.address() and calling setDictionaly
on the obtained address may be racing with Cleaner thread invoking
ZStreamRef.run():
What about making the native setDictionary method as an instance
method (currently it's a static method) so that this object remains
strongly reachable until the method returns?
Mandy
This is a possibility too, yes. In general there might be other places
where the same could be performed. It is equivalent to puting
Reference.reachabilityFence(this) after the invocation of
setDictionary() static native method. But this would only fix public
setDictionary() instance method. There might be other public methods
with similar problems. Synchronizing the ZStreamRef.run() method fixes
all of them in one place.
Regards, Peter