Home > Blockchain >  fatal error: Illegal thread-state encountered: 4...How to prevent this?
fatal error: Illegal thread-state encountered: 4...How to prevent this?

Time:06-21

I am a beginner in programming, and I have an issue with Java. Since 2-3 months ago, my programs occasionally crash with this error:

A fatal error has been detected by the Java Runtime Environment:
Internal Error (safepoint.cpp:712), pid=14516, tid=0x0000000000009f0b
fatal error: Illegal threadstate encountered: 4
JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode bsd-amd64 compressed oops)
Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

An error report file with more information is saved as:
/Users/John/NetBeansProjects/Lab15/hs_err_pid14516.log

If you would like to submit a bug report, please visit:
http://bugreport.java.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

I would appreciate it if someone can help me to understand how to prevent this. I have been programming in Java for fun for a few years, and I have never encountered this issue before. I am using Netbeans 8.2 and Java 1.8.0_333. My OS is Monterey 12.3.1.

Thank you so much!

CodePudding user response:

This phenomenon usually means that your program cannot allocate enough memory. As we know, Java program runs on JVM, and JVM needs to allocate memory space from the operating system. For more detailed error reasons, you need to view the contents of the hs_err_pidxxx.log file

CodePudding user response:

Although you said you're using Java 1.8.0_333, the error message says it's from a much older Java 1.8.0_111-b14.

It's common for people to have more than one JDK on their computer. MacOS ships with an ancient JDK :-( And it can't be removed :-( But there is a workaround :-)

It sounds like you have a newer JDK installed. To ensure it actually gets used, define the JAVA_HOME environment variable in your shell profile (probably in .zshrc). Many web articles show how, such as this one from Baeldung.

I hope this helps.

  •  Tags:  
  • java
  • Related