且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是什么导致 Python 分段错误?

更新时间:2021-09-30 19:33:36

当 python extension(用 C 编写)试图访问无法访问的内存时会发生这种情况.

This happens when a python extension (written in C) tries to access a memory beyond reach.

您可以通过以下方式对其进行跟踪.

You can trace it in following ways.

  • Add sys.settrace at the very first line of the code.
  • Use gdb as described by Mark in this answer.. At the command prompt

gdb python
(gdb) run /path/to/script.py
## wait for segfault ##
(gdb) backtrace
## stack trace of the c code