gdb在python+pybind11上显示java?

ddrv8njm  于 2021-07-05  发布在  Java
关注(0)|答案(1)|浏览(306)

我用一些python+pybind11(c++)代码遇到了segfault。我试图在gdb中调试,但是stacktrace最终 libjvm 我不知道它是从哪里来的。现在我完全不知道我能做些什么来诊断这个问题。
有什么建议吗?

(colin) colinf@spark-ultra-1:~$ gdb python -ex 'r test.py'
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...done.
Starting program: /home/jupyterhub/miniconda3/envs/colin/bin/python test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff4a03700 (LWP 14958)]
[New Thread 0x7ffff4202700 (LWP 14959)]
[New Thread 0x7fffefa01700 (LWP 14960)]
[New Thread 0x7fffed200700 (LWP 14961)]
[New Thread 0x7fffea9ff700 (LWP 14962)]
[New Thread 0x7fffe81fe700 (LWP 14963)]
[New Thread 0x7fffe59fd700 (LWP 14964)]
[New Thread 0x7fffe31fc700 (LWP 14965)]
[New Thread 0x7fffe09fb700 (LWP 14966)]
[New Thread 0x7fffe01fa700 (LWP 14967)]
[New Thread 0x7fffdd9f9700 (LWP 14968)]
[New Thread 0x7fffd91f8700 (LWP 14969)]
[New Thread 0x7fffd69f7700 (LWP 14970)]
[New Thread 0x7fffd41f6700 (LWP 14971)]
[New Thread 0x7fffd19f5700 (LWP 14972)]
[New Thread 0x7fffcf1f4700 (LWP 14973)]
[New Thread 0x7fffce9f3700 (LWP 14974)]
[New Thread 0x7fffcc1f2700 (LWP 14975)]
[New Thread 0x7fffc99f1700 (LWP 14976)]
DEBUG:root:1570235349409078
INFO:root:Processing date=2019-10-05
[New Thread 0x7fffbd9ff700 (LWP 14977)]

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffa79c92b4 in ?? ()
(gdb) bt

# 0  0x00007fffa79c92b4 in ?? ()

# 1  0x0000000000000246 in ?? ()

# 2  0x00007fffa79c9160 in ?? ()

# 3  0x00007fffb7fb3f30 in VM_Operation::_names () from /usr/lib/jvm/java-8-oracle//jre/lib/amd64/server/libjvm.so

# 4  0x00007fffffff7120 in ?? ()

# 5  0x00007fffb7ae178d in VM_Version::get_processor_features() () from /usr/lib/jvm/java-8-oracle//jre/lib/amd64/server/libjvm.so

Backtrace stopped: previous frame inner to this frame (corrupt stack?)

我也尝试了faulthandler,但在命中segfault后没有看到任何回溯

python -q -X faulthandler
>>> import test

...
Segmentation fault
pcww981p

pcww981p1#

如果你使用 pybind11 加载一些本身加载jvm的东西,这是意料之中的。jvm安装信号处理程序并截获这些错误。为了调试同样涉及jvm的程序,您需要告诉gdb通过 SIGSEGV 以及 SIGBUS 向程序发送信号:

(gdb) handle SIGSEGV noprint nostop pass
Signal        Stop  Print   Pass to program Description
SIGSEGV       No    No  Yes     Segmentation fault
(gdb) handle SIGBUS noprint nostop pass
Signal        Stop  Print   Pass to program Description
SIGBUS        No    No  Yes     Bus error

相关问题