search
HomeJavaHow to make the JVM exit quickly after a SIGSEGV crash?

php editor Xigua will give you the answer. When the JVM encounters a SIGSEGV crash, you can take some measures to exit quickly. First, you can set the JVM parameter -XX: CrashOnOutOfMemoryError to cause the JVM to crash and exit quickly when memory overflows. Secondly, you can use Java's exception handling mechanism to catch SIGSEGV exceptions, and call the System.exit() method to exit the program after catching the exception. In addition, you can also use the JNI interface to interact with the operating system and achieve quick exit by calling the exit method provided by the operating system. In short, by properly setting JVM parameters and using appropriate exception handling mechanisms, the JVM can quickly exit after a SIGSEGV crash and improve the stability and reliability of the program.

Question content

One of our services crashes frequently due to some issues with tensorflow java. We can live with that (k8s will restart it, many instances). The problem is that the jvm takes several minutes to terminate. Is there a way to force a fast exit of sigsegv in native code?

corrupted size vs. prev_size while consolidating
#
# a fatal error has been detected by the java runtime environment:
#
#  sigsegv (0xb) at pc=0x00007fe4f321a898, pid=1, tid=545
#
# jre version: openjdk runtime environment zulu21.28+85-ca (21.0+35) (build 21+35)
# java vm: openjdk 64-bit server vm zulu21.28+85-ca (21+35, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# problematic frame:
# c  [libc.so.6+0x28898]  abort+0x178
#
# core dump will be written. default location: /data/core
#
# an error report file with more information is saved as:
# /data/hs_err_pid1.log

A few minutes later:

# [ timer expired, abort... ]
[thread 1037 also had an error]

Solution

Add the following jvm options:

-xx:+suppressfatalerrormessage -xx:-createcoredumponcrash

This will force the jvm to terminate immediately on sigsegv without creating an error report or core dump. If you still want to see fatal error messages, replace -xx: suppressfatalerrormessage with -xx:errorlogtimeout=1.

I suspect this jvm is running with a fairly large heap (> 64 gb), and for a process using so much memory, writing out the core dump file just takes a while:

# Core dump will be written. Default location: /data/core

During the few minutes this takes, you may see the core dump file growing at the above location (this would be an easy way to confirm this theory).

The remedy is to disable the creation of core dump files, the details of which depend on your specific operating system (but core dumps can be disabled on almost any unix-based operating system). Additionally, there may be some filesystem-related bottlenecks at that particular location, causing the core dump to be written slower than expected.

The above is the detailed content of How to make the JVM exit quickly after a SIGSEGV crash?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:stackoverflow. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.