1

I do the build process by means of SBT, with a lot of parallelism. Sometimes, SBT dies and by looking at its console output it doesn't tell the cause.

I have made an exit hook in the JVM, and it is called. So, I discard the JVM is crashing.

How can I diagnose the cause?. Maybe someone is calling System.exit(), or the memory is exhausted.

If I repeat the build, then it succeeds. It is a quite deterministic process, except for the mentioned problem I'm experiencing.

It fails about 5 or 10% of times.

UPDATE 1:

One idea is to use the -XX:onError option of the JVM.

I already have this code (in Scala language) when booting the JVM, in order to diagnose who is killing the JVM:

System setSecurityManager new SecurityManager() {
    override def checkPermission(perm: Permission) = {}

    override def checkPermission(perm: Permission, context: scala.Any) = {}

    override def checkExit(status: Int) = {
        super.checkExit(status)
        println("Trying to exit from: ")
        Thread.currentThread.getStackTrace.foreach { p ⇒
            println(p.toString)
        }
    }
}

but no output is shown.

I'm using Linux (CentOS 7)

david.perez
  • 6,090
  • 4
  • 34
  • 57
  • 1
    have you tried strace (if on Linux)? – JiriS Apr 06 '17 at 07:09
  • 1
    You could add a security manager to [prevent](http://stackoverflow.com/questions/5549720/how-to-prevent-calls-to-system-exit-from-terminating-the-jvm) a `System.exit` and watch till it occurs to ascertain if that's the reason. – Rajeev Sreedharan Apr 06 '17 at 07:16
  • 2
    See [Finding out who calls jvm shutdown hook](http://stackoverflow.com/questions/42091522/finding-out-who-calls-jvm-shutdown-hook) – apangin Apr 06 '17 at 07:21
  • Thanks for all the valuable tips. – david.perez Apr 06 '17 at 08:02

0 Answers0