RE: JavaMemoryModel: Another Java threading issue (finalization)

From: David Holmes (dholmes@dltech.com.au)
Date: Mon Mar 24 2003 - 07:21:00 EST


Hans Boehm wrote:
> The C.finalize() method removes the corresponding data from
> the A array.
>
> Now consider a method C.foo() which may be the last call on
> a C object. Assume that x of class C is accessed by a
> single thread. Typically x.foo() will do something like:
>
> x_index = x.index;
> Operate on A[x_index];
>
> The problem is that x may be unreachable after the read of
> x.index. (Or potentially much earlier, if that memory read
> was for example moved outside an enclosing loop.) Thus the
> operation on A[x_index] may occur after x's finalizer has
> run, and the data associated with x has been removed from A.

Could you clarify what the problem is here. I don't see how an object
can become unreachable whilst a method invocation upon it is in
progress. There must be a reference to the object in the callers stack
at least.

Thanks,
David Holmes

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



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