You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Oliver Deakin <ol...@googlemail.com> on 2007/10/12 18:25:31 UTC

[launcher] Uncaught exceptions not printed on J9 VME

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 in 
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?

Regards,
Oliver

[1] 
http://mail-archives.apache.org/mod_mbox/harmony-dev/200609.mbox/%3ce29119980609210001o59b2f252s85e4b8d451a80ff6@mail.gmail.com%3e

[2]
public class HelloWorld {
    public static void main(String[] args) {
        throw new RuntimeException("hello");
    }
}

[3] 
http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/invocation.html#wp16553

[4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Spark Shen <sm...@gmail.com>.
+100

I have long suffered from this issue. And I think I was a little lazy not to
report this. :-)

Another issue about the stack trace being printed for uncaught exceptions
is the trace is not linked with source code.
Although it can report line numbers where the exception occurs.
For example, on RI the trace is
java.lang.RuntimeException <http://Source_of_RuntimeException>: hello
 at Test.main(Test.java:6 <http://sixth_line_of_Test.java>)

While on Harmony classlib with the J9 VME, the trace is plain text:
java.lang.RuntimeException: hello
 at Test.main(Test.java:6)

To link the source code with the trace will make the stacke trace more
handy.


2007/10/13, Oliver Deakin <ol...@googlemail.com>:
>
> 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 in
> 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?
>
> Regards,
> Oliver
>
> [1]
>
> http://mail-archives.apache.org/mod_mbox/harmony-dev/200609.mbox/%3ce29119980609210001o59b2f252s85e4b8d451a80ff6@mail.gmail.com%3e
>
> [2]
> public class HelloWorld {
>    public static void main(String[] args) {
>        throw new RuntimeException("hello");
>    }
> }
>
> [3]
> http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/invocation.html#wp16553
>
> [4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454
>
> --
> Oliver Deakin
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>


-- 
Spark Shen
China Software Development Lab, IBM

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Alexey Varlamov <al...@gmail.com>.
2007/10/15, Oliver Deakin <ol...@googlemail.com>:
>
> > I would say go ahead and make the change in main.c. Then we'll see
> > whether the problem in HARMONY-3532 is back or not.
> >
>
> Committed at r584804.
Regression test, please?

>
> Regards,
> Oliver
>
> --
> Oliver Deakin
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Oliver Deakin <ol...@googlemail.com>.
> I would say go ahead and make the change in main.c. Then we'll see 
> whether the problem in HARMONY-3532 is back or not.
>

Committed at r584804.

Regards,
Oliver

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Gregory Shimansky <gs...@apache.org>.
Oliver Deakin wrote:
> Gregory Shimansky wrote:
>> Leo Li wrote:
>>> On 10/15/07, Alexey Varlamov <al...@gmail.com> wrote:
>>>> 2007/10/15, Alexey Varlamov <al...@gmail.com>:
>>>>> 2007/10/14, Gregory Shimansky <gs...@apache.org>:
>>>>>> <SNIP>
>>>>> 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.
>>
> 
> I take it the patches applied as part of HARMONY-3532 did not fully 
> resolve the issue?
> 
> It seems from the changes in the spec linked by Alexey that we are now 
> allowed to detach the main thread and, in fact, we are expected to do so 
> on the main thread if we wish any registered exception handlers to be 
> called. It seems, as you suggest, that this is now something that should 
> be fixed in DRLVM to match the RI.
> 
> Is it ok for me to go ahead and add the DetachCurrentThread() call to 
> main.c immediately, or is HARMONY-3532 a big enough issue that you would 
> like me to wait for it to be resolved first?

I would say go ahead and make the change in main.c. Then we'll see 
whether the problem in HARMONY-3532 is back or not.

-- 
Gregory


Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Oliver Deakin <ol...@googlemail.com>.
Gregory Shimansky wrote:
> Leo Li wrote:
>> On 10/15/07, Alexey Varlamov <al...@gmail.com> wrote:
>>> 2007/10/15, Alexey Varlamov <al...@gmail.com>:
>>>> 2007/10/14, Gregory Shimansky <gs...@apache.org>:
>>>>> <SNIP>
>>>> 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.
>

I take it the patches applied as part of HARMONY-3532 did not fully 
resolve the issue?

It seems from the changes in the spec linked by Alexey that we are now 
allowed to detach the main thread and, in fact, we are expected to do so 
on the main thread if we wish any registered exception handlers to be 
called. It seems, as you suggest, that this is now something that should 
be fixed in DRLVM to match the RI.

Is it ok for me to go ahead and add the DetachCurrentThread() call to 
main.c immediately, or is HARMONY-3532 a big enough issue that you would 
like me to wait for it to be resolved first?

Regards,
Oliver

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Gregory Shimansky <gs...@apache.org>.
Leo Li wrote:
> On 10/15/07, Alexey Varlamov <al...@gmail.com> wrote:
>> 2007/10/15, Alexey Varlamov <al...@gmail.com>:
>>> 2007/10/14, Gregory Shimansky <gs...@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 in
>>>>> 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.

-- 
Gregory


Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Oliver Deakin <ol...@googlemail.com>.
Leo Li wrote:
> On 10/15/07, Alexey Varlamov <al...@gmail.com> wrote:
>   
>> 2007/10/15, Alexey Varlamov <al...@gmail.com>:
>>     
>>> <SNIP!>
>>> 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.
>
>   

I just checked and this bug has not been fixed in jdk 1.6 either, so it 
seems that we are still expected to call DetachCurrentThread() before 
DestroyJavaVM when using the RI.

Regards,
Oliver

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Leo Li <li...@gmail.com>.
On 10/15/07, Alexey Varlamov <al...@gmail.com> wrote:
> 2007/10/15, Alexey Varlamov <al...@gmail.com>:
> > 2007/10/14, Gregory Shimansky <gs...@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 in
> > > > 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.

>
> > Moreover, I suggest to add a regression test for this issue (like the
> > one in [4]) so the decision would stay locked in.
> >
> > [4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454
> > --
> > Alexey
> >
> > >
> > > --
> > > Gregory
> > >
> > >
> >
>


-- 
Leo Li
China Software Development Lab, IBM

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Alexey Varlamov <al...@gmail.com>.
2007/10/15, Alexey Varlamov <al...@gmail.com>:
> 2007/10/14, Gregory Shimansky <gs...@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 in
> > > 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

> Moreover, I suggest to add a regression test for this issue (like the
> one in [4]) so the decision would stay locked in.
>
> [4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454
> --
> Alexey
>
> >
> > --
> > Gregory
> >
> >
>

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Alexey Varlamov <al...@gmail.com>.
2007/10/14, Gregory Shimansky <gs...@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 in
> > 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 ;)
Moreover, I suggest to add a regression test for this issue (like the
one in [4]) so the decision would stay locked in.

[4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454
--
Alexey

>
> --
> Gregory
>
>

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Sean Qiu <se...@gmail.com>.
This would be really helpful.

2007/10/15, Gregory Shimansky <gs...@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 in
> > 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.
>
>
> --
> Gregory
>
>


-- 
Sean Qiu
China Software Development Lab, IBM

Re: [launcher] Uncaught exceptions not printed on J9 VME

Posted by Gregory Shimansky <gs...@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 in 
> 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.


-- 
Gregory