This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
NullPointerException / threads
- To: java-discuss at sourceware dot cygnus dot com
- Subject: NullPointerException / threads
- From: Andrew Haley <aph at pasanda dot cygnus dot co dot uk>
- Date: 14 Mar 2000 14:14:01 -0000
When gcj first starts, we create a single NullPointerException which
is thrown whenever a SEGV is caught by the runtime. In order to give
the user some useful information about where the exception occurred,
we call the exception's fillInStackTrace method before throwing.
Clearly, this will cause problems if two threads throw the same
NullPointerException at the same time; one will corrupt the other's
backtrace.
In order to solve this problem, we could create a new
NullPointerException in the context of the signal handler, but that
may crash if the SEGV occurs in the memory allocator itself. Also,
fillInStackTrace calls JvNewByteArray to hold the stack trace, and if
this fails we'll crash anyway, so maybe a SEGV handler shouldn't even
be calling fillInStackTrace.
I suppose we could create a NullPointerException and a pre-allocated
stacktrace for each thread when it starts, but that seems rather
nasty.
Opinions?
Andrew.