weird GC problem

Jeff Sturm jeff.sturm@appnet.com
Sat Dec 23 15:42:00 GMT 2000


Jeff Sturm wrote:
> I've been trying for a few days to track down a mysterious crash in some
> Java code, using a recent gcc snapshot.  So far I haven't produced a
> simple test case... small classes never exhibit the problem.

Got it!  Thanks to Tom and Bryce for the debugging tips.

It's not a case of premature finalization at all, rather its an ordinary
libgcj bug.  Through careful debugging I discovered exactly two
FileDescriptor objects in memory with fd == 0.  One was assigned to
FileDescriptor.in and is a live object.  The other gets finalized,
closing stdin.

The challenge was figuring out where this imposter FileDescriptor came
from.  The typical constructor performs a native open:

  fd = open(path, mode);

Seemingly this will always return a valid fd, or -1.  But if <path> does
not exist, open() throws a FileNotFoundException instead, so the
assignment above never takes place, and fd remains initialized to zero,
which is a valid file descriptor!

Patch coming soon...

Jeff


More information about the Java mailing list