Possible exception handling bug

Project:JNode Core
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

I think I've tracked down one possible cause for the "Current thread is not the owner of this monitor" errors we sometimes see.

I've managed to get it to happen reproducibly in my hacked around version of the command shell. I think I've tracked it down to this:

try {
synchronized (this) {
...
// call something that throws an exception
...
} // end synchronized
catch (Throwable ex) {
ex.printStackTrace();
}

This is a simplified version of my code. My code goes into an infinite loop when an exception occurs, outputting the above error message via Unsafe.debug().

Here's the interesting bit. If I change the code to move the "try ... catch ..." block inside the "synchronized ..." block, the problem goes away.

Based on this, I suspect that JNode is not properly handling some cases where a thrown exception unwinds through monitor.

A screenShot

hallo crawley,
Please can you provide a ScreenShot of the Exceptions are throwing there in your Code?
Please once try to give that.....
See U!
Thanks
Tango

No I cannot

... because when it gets into that state it is in an infinite loop spewing messages to the screen as fast as it can.

There should be sufficient detail in the bug report to reproduce this. For example, you could hack the CommandShell class to throw some exception within the try / catch block I identified.

trying that better.....

hai crawley;
Ok...i trying to find out the Exceptions again....Your option is better..because compiling with a different small source ,beyond the total huge sources of the BASH is better for looking into the Bugs.......i just trying....
See U!
Thanks
Tango

Progress and A WORKAROUND !

Andreidore has done a lot of investigation on this bug; see this forum topic. He has discovered that the root of the problem is that the Sun and Eclipse compilers are gerenerating bytecode files with different exception tables. It appears that the JNode native code compiler is generating incorrect code for the Eclipse version.

So the workaround (for users of Eclipse) is to make sure that you build with the Sun compiler.

I couldn't figure out how to tell Eclipse to use the Sun compiler. So I achieved the required result by telling Eclipse to write its bytecode files to different locations to those specified in the Any files. For each Project, I did the following:

  1. Open the Project's properties.
  2. Open Java Build Path in properties tree view.
  3. Select the Source tab
  4. Change the Default Output Folder from "build/classes" to (say) "build/eclasses".
  5. Click on the OK button to save the changes.

Finally, you should run "./build.sh clean" to remove any class files compiler by Eclipse from the Ant build trees.

#1

Status:active» closed

fixed in trunk

#2