AsyncGetCallTrace() is called from a SIGPROF signal handler and provides
a data buffer into which call frames are stored. A per-thread call frame
buffer could be attached to thread local storage to ease implementation
of the SIGPROF signal handler.
There are a couple of issues with using JVM/PI GetThreadLocalStorage()
and SetThreadLocalStorage() in a signal handler:
- the methods are currently JVMPI_ENTRY() points and indirectly use a
HandleMarkCleaner. The HandleMarkCleaner finds the lowest HandleMark
on the stack and cleans up the Handles to that point. When called
from a SIGPROF signal handler, this causes random Handles to be
cleaned up. This results in strange hangs and crashes due to objects
being unlocked, freed, and overwritten. In short, carnage ensues.
- the methods do not check the return value from
JavaThread::thread_from_jni_environment() before using it. This means
that toward the end of a thread's life, a NULL pointer dereference
can crash the VM.