Search code examples
javajava-native-interfacecrash-dumps

How does a Java process die?


A quick answer would be "without crying" of course :).

I have a really strange problem with my Java application (J2SE 1.7) on a Win7 32bits system. I encountered all the cases :

  • Sometimes it goes out of memory of Java heap (and so I can log it and recover from this)
  • Sometimes it crash in the native and I have the hs_err_pidxxxx.log file and I can analyze what is going on.
  • Sometimes it crash in the native and I have no hs_err file but I have a popup java stop functioning and I can see the exception in windows event log and even debug with visual some part of the process.
  • Sometimes it crash and I have nothing (no hs_err, no popup, nothing...). It just ends all like if there were an System.exit() or a native exit() call.

So my question is :

  • how can I be sure this is a native exit call as I don't have all the code of native libraries I am using ?
  • Is it possible to have this strange behaviour produced by another mean ?
  • Finally how to debug and track which lib can be the root cause ?

Solution

  • how can I be sure this is a native exit call as I don't have all the code of native libraries I am using ?

    The only way I know to be sure would be to wrap the call to a native library with logging commands so you log before each call and after each return. After your program has crashed if the log has an enter message but no return message then that library call is suspect.

    Is it possible to have this strange behaviour produced by another means ?

    Yes there are an infinite number of strange other means. Using up memory or some other resource might be one explanation.

    Finally how to debug and track which lib can be the root cause ?

    Logging described above should find this too if the messages are specific to which library is being called. You can monitor the application in jconsole to see if it is using up tons of memory or threads. Disable anything that can be disabled so you can eliminate it as being part of the problem. If the problem goes away enable things one at atime until the problem returns.