[concurrency-interest] DirectByteBuffers and reachabilityFence

Andrew Haley aph at redhat.com
Thu Dec 10 04:28:22 EST 2015


On 10/12/15 02:15, Gil Tene wrote:
> 
> I actually do think that 'this' is special. And that the specific
> mishandling of 'this' by the current spec and implementations is
> responsible for a ton of lurking races like the ones in DBB.get()
> and put(). Wile I see a separate need for things like explicit
> reachability fences in other cases (not 'this' related), I think for
> 'this' the fundamental problem can be stated this way:
> 
> "It is fundamentally surprising behavior for an instance to become
> unreachable while code in one of its instance methods is still
> executing."

What, though, is your justification for such a statement?  Is it
simply to make the specification align with intuitive reasoning?  I'm
not saying that alignment with intuition is a bad thing, but as far as
I can see that's all it is.

> This is the root of all these current could-access-a-freed-buffer in
> DBB. It is also the root of many simple finalizer issues (though not
> all). And it is probably a common root for many patterns that access
> memory at an address stored in a long field of an instance. Any
> solution where you were going to use reachabilityFence(this) (as
> opposed to some other field or local variable) is an indication of
> this problem.

That's certainly true.

Andrew.


More information about the Concurrency-interest mailing list