python segmentation fault

1:使用faulthandler 调试
在代码中加入
import faulthandler;faulthander.enable()

然后通过python3 -Xfaulthander xx.py 执行.

打印挂掉是的堆栈
Thread 0x0000ffffbb0d8b20 (most recent call first):
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1443 in _call_tf_sessionrun
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1350 in _run_fn
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1365 in _do_call
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1359 in _do_run
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1180 in _run
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 956 in run

2:通过frame.f_code.co_filename,frame.f_lineno 来显示调用文件的name和行号,通过event显示事件,这里的事件就是call 调用
def trace(frame,event,arg):
    print("%s, %s:%d" % (event,frame.f_code.co_filename,frame.f_lineno))
    return trace
sys.settrace(trace)


import sys
def trace(frame,event,arg):
    print("%s, %s:%d" % (event,frame.f_code.co_filename,frame.f_lineno))
    return trace
sys.settrace(trace)
print("hello")


[root@localhost rpm]# python2 hello.py
hello
call, /usr/lib64/python2.7/_weakrefset.py:38
call, /usr/lib64/python2.7/_weakrefset.py:38


3:通过gdb 中执行
[root@localhost rpm]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-6.el8
Copyright (C) 2018 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 "aarch64-redhat-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".
(gdb) file python2
Reading symbols from python2...Reading symbols from .gnu_debugdata for /usr/bin/python2.7...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: yum debuginfo-install python2-2.7.16-12.module_el8.1.0+219+cf9e6ac9.aarch64
(gdb) run hello.py
Starting program: /usr/bin/python2 hello.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
hello
call, /usr/lib64/python2.7/_weakrefset.py:38
call, /usr/lib64/python2.7/_weakrefset.py:38
[Inferior 1 (process 45468) exited normally]

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值