[concurrency-interest] DirectByteBuffers and reachabilityFence

Justin Sampson jsampson at guidewire.com
Thu Dec 10 18:48:29 EST 2015


David Holmes wrote:

> > > No! The object should not be able to become finalizable until
> > > after all its constructors have completed, and then it becomes
> > > unreachable.
> >
> > Is this your view of the existing world, or what you are
> > proposing be changed? I'm losing track of what's what in this
> > discussion. :-)
>
> This is how the existing world should have been if the JLS update
> had not been snafu'd. Justin would argue it should be the current
> state regardless due to happens-before definition. Regardless the
> JVM does not currently implement this.

Jeremy Manson seemed to think it had been implemented this way,
based on the happens-before wording, back in 2010:

http://jeremymanson.blogspot.com/2010/01/garbage-collection-references.html

I'm having trouble finding any other concrete references to how it's
actually implemented, but I suppose it's not worth trying to nail it
down unless someone has a legitimate piece of code that's failing.

To summarize the thread again, there have been several questions:

1. Does the spec allow an object's memory to be freed in the middle
of one of its own instance methods?

Everyone seems to agree that the answer is Yes, but there is still
ongoing discussion of whether the spec could be changed, or whether
reachabilityFence() is the best we can hope for.

2. Does any JVM actually do #1?

Yes, Alexandre provided a working example with a segfault.

3. Does the spec allow a finalizer to be run concurrently with the
same object's own constructor?

I say No, David says Maybe, but everyone agrees that the intent was
to forbid it and it's probably worth clarifying in the spec.

4. Does any JVM actually do #3?

A few people say Yes, but we haven't looked at any running examples
in this particular discussion.

Cheers,
Justin



More information about the Concurrency-interest mailing list