5

Python script generates segmentation fault I cannot find the source of the problem. How is it to debug a segfault simply in Python ? Are there recommended coding practices to avoid Segmentation Faults ?

I wrote a script (1600 lines) to systematically download CSV files from a source and format the collected data. The script works very well for 100-200 files, but it systematically crashes with a segmentation fault message after a while.
-Crash always happens at the same spot in the script, with no understandable cause -I run it on Mac OSX but the crash also happens on Ubuntu Linux and Debian 9 -If I run the Pandas Routines that crash during my script on single files, they work properly. The crash only happens when I loop the script 100-200 times. -I checked every variable content, constructors (init) and they seem to be fine.

Code is too long to be pasted, but available on demand

Expected result should be execution to the end. Instead, it crashes after 100-200 iterations

Emanolo78
  • 309
  • 5
  • 10
  • 2
    A segmentation fault in a Python script is a bug in Python or one of the libraries. It's not usually something in your program that you can debug. – Barmar Dec 25 '18 at 21:45
  • It’s possible to run `python` under a debugger and convert the segfault into a Python exception—just to get a traceback to narrow the candidates. It’s unwise to try to continue from such a state, and the buggy C code (as Barmar said) may have run in a separate call *before* the arrival of the signal. – Davis Herring Dec 26 '18 at 00:07
  • Relevant [python-memory-leaks](https://stackoverflow.com/questions/1435415/python-memory-leaks) – stovfl Dec 26 '18 at 09:41

0 Answers0