harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregory Shimansky <gshiman...@apache.org>
Subject Re: [launcher] Uncaught exceptions not printed on J9 VME
Date Mon, 15 Oct 2007 12:20:13 GMT
Leo Li wrote:
> On 10/15/07, Alexey Varlamov <alexey.v.varlamov@gmail.com> wrote:
>> 2007/10/15, Alexey Varlamov <alexey.v.varlamov@gmail.com>:
>>> 2007/10/14, Gregory Shimansky <gshimansky@apache.org>:
>>>> Oliver Deakin wrote:
>>>>> Hi all,
>>>>> A little while back there was a thread called "[drlvm] Should the
>>>>> launcher print uncaught exceptions?" [1] where we discussed the fact
>>>>> that running a test case like [2] did not print a stack trace with the
>>>>> Harmony launcher. As part of this discussion, HARMONY-1819 was raised
>>>>> and the line "(*jvm)->DetachCurrentThread(jvm)" was added to the
>>>>> launcher main.c in repo revision r464443.
>>>>> HARMONY-3713 was later raised pointing out that calling
>>>>> DetachCurrentThread() to detach the main thread was contrary to the spec
>>>>> [3], and the line was removed from main.c. However, I have just noticed
>>>>> that if you run [2] on the current J9 VME (and, in fact, on the RI with
>>>>> a simple launcher) you do not get any stack trace printed, and I imagine
>>>>> this has been the case since the commit of HARMONY-3713.
>>>>> The RI has a bug [4], contrary to the spec [3], which requires
>>>>> DetachCurrentThread() to be called by the invoking launcher if you wish
>>>>> to see the stack trace of an uncaught exception. It appears that J9 has
>>>>> matched this bug, probably so no unexpected trace is printed in
>>>>> launchers programmed against the RI.
>>>>> So currently running Harmony classlib with the J9 VME will not result
>>>>> any stack trace being printed for uncaught exceptions, which makes
>>>>> debugging issues where that occurs more troublesome. Id like to propose
>>>>> that the DetachCurrentThread() line be readded to main.c (i.e. the
>>>>> opposite of the patch for HARMONY-3713), perhaps with a comment to show
>>>>> that this is to match the behaviour of the RI rather than the spec.
>>>>> Any objections?
>>>> I wonder if simply adding
>>>> if ((*env)->ExceptionCheck(env))
>>>>     (*env)->ExceptionDescribe(env);
>>>> is enough to print out stack trace in the main thread without violating
>>>> the spec.
>>> The bug of RI [4] (fixed in 1.5) being referred by Oliver is a bit
>>> wider than just printing out the stack trace. Synopsis reads:
>>> "(thread) setUncaughtExceptionHandler() doesn't work on main thread ".
>>> I believe this is really strong argument to use DetachCurrentThread
>>> and be compatible with RI rather than spec (which should be fixed and
>>> will be someday ;)
>> FYI, spec is indeed fixed in 1.6 :
>> http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#wp16553
> The clue from the change in spec is enough to show that it is
> appropriate to call  DetachCurrentThread() in the main thread when
> shutdowning VM.

Ok if DestroyJavaVM is called after DetachCurrentThread the bug in 
HARMONY-3532 will reappear. It looks like DRLVM shutdown sequence should 
be fixed to execute shutdown hooks when DetachCurrentThread is called 
for the last thread, instead of doing it in DestroyJavaVM.


View raw message