RE: JavaMemoryModel: Finalization idioms

From: Boehm, Hans (hans.boehm@hp.com)
Date: Mon May 02 2005 - 14:37:39 EDT


Eliot -

Hopefully Jeremy answered this.

Register values certainly have to be seen by the collector.
The underlying problem is that an object's method may rely
on state associated with an object (typically contained in
fields of the object or in statically reachable data structures)
long after it no longer needs the "this" pointer itself.
But that state will be invalidated by the finalizer.

To make things worse, I think this is the usual case for
objects that use finalizers. However, the probability that
you will see an actual failure from this is tiny. The issue
has been understood to some extent for a long time. (I think
Barry Hayes pointed out some things along these lines more than
ten years ago.) But saying that it's not be widely appreciated,
is probably a gross understatement.

This is also discussed in more detail in sections 3.3 and 3.4
of my POPL 2003 paper.

Hans

> -----Original Message-----
> From: owner-javamemorymodel@cs.umd.edu
> [mailto:owner-javamemorymodel@cs.umd.edu] On Behalf Of Eliot Moss
> Sent: Monday, May 02, 2005 9:06 AM
> To: David Holmes
> Cc: jmm
> Subject: RE: JavaMemoryModel: Finalization idioms
>
>
> I'm missing something in this discussion ....
>
> Folks Are talking about values in registers not being "seen"
> by a GC. Whether something is in a register, thread stack, or
> heap, the GC had BETTER find it! I suspect that what you are
> getting at has more to do with something being thread-local
> than with it being in a register per se. And if it is
> thread-local, never seen by another thread, then you are
> saying that the point at which it becomes unreachable is not
> easy to capture, given the range of optimizations allowed. Is
> this right?
>
> In particular, I surmise that there is an issue something like this:
>
> Thread T creates a thread-local object that has finalization,
> writes to it, and then drops the pointer on the floor. The GC
> determines the object is unreachable, and then the finalizer
> begins to run. But there is no synchronization to guarantee
> that the original thread's writes are seen by the finalizer.
> Is that the problem you are discussing? This has nothing to
> do with registers -- only with the lack of synchronization
> between becoming unreachable and having your finalizer run.
>
> -- Eliot
> -------------------------------
> JavaMemoryModel mailing list -
> http://www.cs.umd.edu/~pugh/java/memoryModel
>

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:10 EDT