我写了一个hook.so
文件,用libc.so.6
拦截JVM对LD_PRELOAD
的调用。但是当我使用截获的JVM在JVM上运行某些应用程序时,它报告了如下错误:
Aborted (core dumped)
vim /home/hs_err_pid635.log
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fb3e9cd6927, pid=635, tid=0x00007fb3baa8c700
#
# JRE version: OpenJDK Runtime Environment (8.0_151-b12) (build 1.8.0_151- 8u151-b12-0ubuntu0.16.04.2-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.151-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [hook.so+0x8927] find_job+0x33
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# 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.
#
--------------- T H R E A D ---------------
如何根据信息C [hook.so+0x8927] find_job+0x33
找到错误代码行?
谢谢。
答案 0 :(得分:1)
使用调试信息构建hook.so
库:gcc -g
或clang -g
然后使用-XX:+ShowMessageBoxOnError
选项运行JVM。
当JVM下次崩溃时,它会提示您附加调试器。 gdb
将在源代码中显示位置,本地变量值等。