【Linux问题处理】Aborted (core dumped)报错python

原文作者:我辈理想

版权声明:文章原创,转载时请务必加上原文超链接、作者信息和本声明。

文章目录

  • 一、命令检查
    • 1.python执行py文件
    • 2.gdb执行py文件
  • 二、进程检查
    • 1.检查所有python程序
    • 2.使用gdb检查进程
  • 三、core文件检查
    • 1.开启core文件存储能力
    • 2.core文件存储位置
    • 3.gbd查看core文件

首先需要在ubuntu系统安装gdb工具。

sudo apt-get install gdb

gdb是c的工具,常用命令如下:

where # 哪里出问题
bt # 查看栈信息
q # 退出gdb

如果安装了python-dbg,还可以使用以下命令:

py-bt # 查看栈信息
py-list
py-up  # 上一帧(py级别的帧)
py-down  # 下一帧(py级别的帧)
info thread   # 线程信息
thread    # 切换到某个线程
thread apply all py-list  # 查看所有线程的py代码位置
ctrl-c  # 中断

一、命令检查

1.python执行py文件

python3 xxx.py

在这里插入图片描述

2.gdb执行py文件

gdb python3 
run xxx.py

在这里插入图片描述

二、进程检查

1.检查所有python程序

ps -x | grep python

在这里插入图片描述

2.使用gdb检查进程

sudo gdb -p 1199469

在这里插入图片描述

在这里插入图片描述

三、core文件检查

pwd  # 查看当前目录
#  结果:/home/ubuntu
echo /home/ubuntu/core.%p> /proc/sys/kernel/core_pattern # 调整core文件的位置和格式
gdb core-file core.id  # gdb查看core文件

1.开启core文件存储能力

core文件默认是不存储的,ulimit -c 可以改变当前连接,具备文件存储能力。

ulimit -a # 显示目前资源限制的设定
ulimit -c 1024 # 设定core文件的最大值,单位为区块

ulimit -a # 再次查看资源限制

在这里插入图片描述

2.core文件存储位置

core存储在文件/proc/sys/kernel/core_pattern中,可以直接读取

cat /proc/sys/kernel/core_pattern 

在这里插入图片描述

以下是参数列表:

%p – insert pid into filename 添加pid(进程id)

%u – insert current uid into filename 添加当前uid(用户id)

%g – insert current gid into filename 添加当前gid(用户组id)

%s – insert signal that caused the coredump into the filename 添加导致产生core的信号

%t – insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间

%h – insert hostname where the coredump happened into filename 添加主机名

%e – insert coredumping executable name into filename 添加导致产生core的命令名

3.gbd查看core文件


本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/50e1db04f3.html