2

How can I create a thread and core dump on the JVM crash? Does any JVM argument exist which creates a file with these dumps when JVM crash suddenly?

In my case, I need to prepare Java Virtual Machine to create that file.

TravelerVihaan
  • 201
  • 2
  • 6
  • 19
  • 3
    Does this answer your question? [Can Sun JDK generate core/heap dump files when JVM crashes?](https://stackoverflow.com/questions/10944082/can-sun-jdk-generate-core-heap-dump-files-when-jvm-crashes) – Pavel Smirnov Mar 02 '20 at 13:46
  • @PavelSmirnov Not at all. I have to be prepared for some other reasons of crash. Not only on ```OutOfMemoryError```. I also need more detailed informations than heap dump. – TravelerVihaan Mar 02 '20 at 13:47
  • 1
    As said in the answer "dump isn't really needed if JVM crashed due to a different reason". Besides, when Oracle JVM crashes, it automatically creates a log file. What exactly do you want to get from what you call "thread and code dump"? – Pavel Smirnov Mar 02 '20 at 13:50
  • @PavelSmirnov Customer using our application has problem with mysterious crashing. Logs are cut in some place. It is not problem with memory for sure, because they allocated a lot of RAM for VM. I try to collect as more data as I can in moment of crashing the JVM, but run of application is so quick, so it cannot be done manually. – TravelerVihaan Mar 02 '20 at 18:44
  • 1
    Have a look at [this](https://docs.oracle.com/javase/9/troubleshoot/fatal-error-log.htm#JSTGD542) topic. When a JVM (HotSpot at least) crashes it creates a fatal error log (default path is the working directory of the JVM process). It contains plenty of information required to trace the error including the stacktrace, threads, heap, OS and much more. – Pavel Smirnov Mar 02 '20 at 18:53
  • @PavelSmirnov Yes, I read it. But unfortunately no logs were created. I tested it by setting only 1MB RAM for JVM and running java with option ```CrashOnOutOfMemoryError```. In this case logs appeared in directiory where I ran application. I thought that exists any other way to force this logs. I read also about profilers and snapshots from them, but it is too complicated to ask client about doing it. – TravelerVihaan Mar 02 '20 at 19:39
  • 2
    Two questions then. How do you know it's a JVM crash and not something else? Are you sure it's HotSpot? Anyways, try to run the JVM with `-XX:OnError` option and specify a log path. If there's still nothing, I really doubt the problem is caused by a JVM crash. – Pavel Smirnov Mar 02 '20 at 19:56
  • I am not sure if JVM crash at all. Application always starts with bundled JDK 1.8_101. This case is so strange, because program stops without any information. If it had been some crash in code, in logs would be some entries in logs. Maybe the key information is fact, that this problem appeared after upgrading Win7 to Win10, but I have no idea how to use it. – TravelerVihaan Mar 02 '20 at 20:09
  • 1
    There can be lots of reasons. You said the log suddenly interrupts. Is it the same last message all the time? In this case I'd dig into the code, most probably there's an uncaught exception causing the JVM to terminate. – Pavel Smirnov Mar 02 '20 at 22:42
  • @TravelerVihaan To clarify do you have a deadlock or a crash? Does the crash have no stacktrace? Does it at least print out some kind of message. If the application just stops with no error, are you sure System.exit is not being called somewhere? – PiRocks Mar 02 '20 at 23:18
  • @PavelSmirnov Yes, it crashs (or maybe I should say - stops work) in the same moment all the time. It happens in try/catch block with some loggers triggered to print messages about errors. This operation should finish by creating file od disk. Depends on format - the file is cut, or it has 0B and not be generated propertly (to create file are used 3rd party libs). Thats why I know the application stuck right there. I tried to reproduce this in my env, but then files were generated successfully. – TravelerVihaan Mar 03 '20 at 08:01

1 Answers1

4

As stated above, this is solution for OOM.

For other fatal errors jvm provide -XX:OnError Option.

More information.