Segfault using Sage function with try...except AlarmInterrupt

Segmentation fault is a reaction to SEGV (segmentation violation) signal which is sent to a process by the operating system when the process tries to access memory which it is not allowed to access (often unallocated memory).

In pure Python this should never happen unless there is a bug in the Python interpreter. In low-level languages like C this happens most often when you work with pointers incorrectly[1] or when you try to access heap memory which was already freed. But here we do not have (pure) Python…

Here I noticed the .pyx extension and cythonized. This points to the fact that this is a part of SageMath written in Cython, not Python, nor C.

You can try to:

  • examine the lines of the .c file and try to find their source in the .pyx file
  • insert some diagnostic outputs to the .pyx file
  • debug the Cython code using GNU debugger:

https://cython.readthedocs.io/en/latest/src/userguide/debugging.html


  1. e.g. you do not check if you do not cross the destination data structure size as Leland described ↩︎

1 Like