This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Wrong exception handler called?



 Hi Fred,

there is (or was, I haven't checked recent versions) known bug in gcc 
that may cause exactly the problem you're seeing (and it also explains
why other people aren't seeing it, as it depends on how addresses are
reused by the memory allocator.)
See http://gcc.gnu.org/ml/gcc-bugs/1999-12n/msg00120.html

To make sure, you should look at the assembly code produced (-S option)
and manually check the exception handler table.  If the entry that would
correspond to the handler that should be invoked is missing, it's 
probably the same problem.  You can easily find the problem since
the label for the catch clause is emitted, but it never shows up the
handler table.

You could also try the "patch" I suggested in the email above
and see if the problem goes away.  Of course, that patch is not really a fix.
I suggested a while ago to Alexandre that someone add an assertion 
"rtl_stack == &permanent_obstack" to gen_exception_label (as the comment 
there demands).  However, if one adds such an assumption, it would fail 
regularly for the java front-end, which may be indicative of a 
deeper-lying problem.

	- Godmar

> 
> In the process, I stumbled across what seems to be a serious bug in libgcj's
> exception handling.  Under some circumstances, when a single try block has
> multiple catch blocks associated with it, the wrong catch block is invoked.
> 
> Interestingly enough, compiling directly from java source to native code 
> causes the problem to disappear.  Also, if the main() method from Testcase1 is
> merged into Testcase2, the problem goes away.  Consequently, this smells much
> more like a compiler problem than like a runtime problem.
> 
> Thanks very much for your help.
> 
> -- Fred 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]