简体   繁体   English

Java中的SIGSEGV可以不崩溃JVM吗?

[英]Can a SIGSEGV in Java not crash the JVM?

I'm using gdb to debug C code, which is being called from Java. 我正在使用gdb来调试从Java调用的C代码。 I attach the gdb to running Java process and it works. 我将gdb附加到正在运行的Java进程,它可以工作。 Somewhat. 有些。 The curios thing is GDB is periodically reporting SIGSEGV and it doesn't crash Java. 古玩的事情是GDB定期报告SIGSEGV并且它不会使Java崩溃。 I would expect the JVM to go down and generate hs_err_pid with information about the error. 我希望JVM关闭并生成hs_err_pid,其中包含有关错误的信息。 I am wondering if those faults are actually caused by gdb (no idea how) and don't really occur in the running code, or if under some circumstances Java can recover from SIGSEGV (no idea how). 我想知道这些错误是否实际上是由gdb引起的(不知道如何)并且在运行代码中没有真正发生,或者在某些情况下Java可以从SIGSEGV中恢复(不知道如何)。

EDIT: Here is full gdb output: https://pastebin.com/Mk44kWXQ 编辑:这是完整的gdb输出: https//pastebin.com/Mk44kWXQ

Example: 例:

Thread
52 "java" received signal SIGSEGV, Segmentation fault.
0x00007f9f3a93d4b1 in ?? ()
-exec-continue
[New Thread 0x7f9ea4b46700 (LWP 10135)]
[New Thread 0x7f9eb4079700 (LWP 10137)]
[Thread 0x7f9eac95e700 (LWP 10130) exited]

Thread
52 "java" received signal SIGSEGV, Segmentation fault.
0x00007f9f3a93d4b1 in ?? ()
-exec-continue
[Thread 0x7f9ea534c700 (LWP 9960) exited]

Can a SIGSEGV in Java not crash the JVM? Java中的SIGSEGV可以不崩溃JVM吗?

Sure, if a SIGSEGV occurs while executing Java code (not native code) it is most likely due to dereferencing a Java null . 当然,如果在执行Java代码(非本机代码)时发生SIGSEGV,则很可能是由于解除引用Java null That can be trapped and turned into a NullPointerException and "thrown". 这可以被捕获并变成NullPointerException并“抛出”。 An application can recover from this; 应用程序可以从中恢复; ie by "catching" the exception. 即通过“捕获”异常。

I think that a SIGSEGV could also be triggered by a Java stack overflow causing the Java code to read or write an address in a stack's "red zone" memory segment. 我认为SIGSEGV也可能由Java堆栈溢出触发,导致Java代码在堆栈的“红区”内存段中读取或写入地址。

Anyhow, there are definitely scenarios where the JVM's SIGSEGV signal handler may turn the SIGSEGV event into a Java exception. 无论如何,肯定会有JVM的SIGSEGV信号处理程序将SIGSEGV事件转换为Java异常的情况。 You will only get a JVM hard crash if that can't happen; 如果不能发生,你只会遇到JVM硬崩溃; eg if the thread that triggered the SIGSEGV was executing code in a native library when the event happened. 例如,如果触发SIGSEGV的线程在事件发生时正在本机库中执行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM