在 Linux 上运行 Java 程序时出现分段错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19490368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Segmentation fault while running Java program on Linux
提问by juan
I am running a JAVA program on RHEL 6.4 Server. The program terminates abnormally displaying the messaeg "Segmentation fault(Core dumped)". But i do not find any file indicating the reason for termination in the current user directory from where the program was run.
我在 RHEL 6.4 服务器上运行 JAVA 程序。程序异常终止,显示消息“Segmentation fault(Core dumped)”。但是我在运行程序的当前用户目录中没有找到任何表明终止原因的文件。
How can i debug to find the error in such case?
在这种情况下,我如何调试以找到错误?
DOUBT
怀疑
As per my understandin segmentation fault occurs when program tries to access a memory address outside the programs range. I would expect to see such faults in C or C++ programs, but in Java since there are no pointers , how is segmentation fault possible.
根据我的理解,当程序尝试访问程序范围之外的内存地址时,会发生分段错误。我希望在 C 或 C++ 程序中看到这样的错误,但在 Java 中,因为没有指针,分段错误怎么可能。
回答by NPE
how is segmentation fault possible.
分段错误怎么可能。
There are several possible reasons for this. There could be a bug in the JVM itself, or in a package (some of these are written in C or C++). It could also be due to a misconfiguration where incompatible components are used together.
这有几个可能的原因。JVM 本身或包中可能存在错误(其中一些是用 C 或 C++ 编写的)。也可能是由于配置错误,将不兼容的组件一起使用。
From experience, a JVM bug is the least likely of these (although I've seen some).
根据经验,JVM 错误是其中最不可能的(尽管我见过一些)。
If you capture the stack trace at the point of the crash, this might give you some clues as to where exactly the crash is occurring.
如果您在崩溃点捕获堆栈跟踪,这可能会为您提供有关崩溃确切发生位置的一些线索。