How to debug silent crashes in Java applications?

I am trying to debug a problem in my Java application that does not cause errors, exceptions, or even break the application (it seems that the crash is happening in a separate thread).

The problem is the library function call (this is JAXBContext.newInstance(String) if that matters). The program will reach the line immediately before the call, but not immediately after it. My catch blocks are not entered and the program continues to run.

The problem occurs when you try to map an XML response to a web request that comes through Struts. The request is processed, and the code must marshal the response object. The client immediately receives a response (so the code does not seem to hang in a loop), but it is simply empty.

I set a breakpoint just before the problematic line, but the debugger just runs through it, I don’t know why.

I use eclipse and the application runs inside the OSGi container (Apache Felix), which was launched using -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y . Inside Eclipse, I use the Debug settings for the “Remote Java Application” to connect the debugger.

What are the methods to solve this problem?

+5
java debugging eclipse remote-debugging
Jun 24 '09 at 9:36
source share
4 answers

Probably the obvious question, but are you sure you are catching Throwable? An unchecked exception could easily make the thread in question die (assuming none of you in the call stack catch it.)

Since you suspend the virtual machine at startup using debugging arguments, I assume that you have confirmed that the debugger is installed correctly. The fact that you are saying that the debugger passes right past the call is very suspicious. Can you hit any breakpoints in this application? And what is in this class? What's in this thread?

How did you narrow this line down without a debugger? println / debug to file?

Is it possible to insert a code fragment of this method?

You could confirm the theory that a thread dies, creating a second thread before the problem occurs and attaching it to a thread that you think is dying. Then the second run () method of the thread will be called when the thread in question exits and you find out that he died (but still would not know why.)

In response to your general question, when I have a bug in a Java application that I cannot reproduce in the debugger (which happens from time to time for various reasons), I gradually change my code using sysout printlns or file output. If necessary, I can also change the code that calls my code. If you do not have the source code for the code you are calling, you can try one of the many BCI frameworks to inject your bytecode into the appropriate methods. This is a tedious process, but only happens sometimes.

+6
Jul 16 '09 at 17:48
source share
— -

You can try to get a Dump Dump - this will tell you if any methods are blocked (for example, waiting for input). [Edit: re-reading the original question, getting a dump of the thread probably won't help, since it seems like nothing is actually blocking. But I leave it here because I find it useful in many other situations!]

If you think the error is occurring in a different thread, you can also set UncaughtExceptionHandler to try to catch it.

+2
Jun 24 '09 at 9:52
source share

If you are sure that the problem is somewhere inside this method, you can try looking at the JAXB source code .

EDIT:

Well, if it gets really bad, you can create your own private copy using debugging tools. I hope you do not have to resort to this.

+1
Jun 24 '09 at 9:49
source share

perhaps there’s an endless loop inside the call, and so you don’t get more - but it may not cause a failure (if memory is not used in each loop).

0
Jun 24 '09 at 9:40
source share



All Articles