473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Debugging segmentation faults

I have a pure python program (no C extensions) that occasionally core
dumps in a non-reproducible way. The program is started by a (non-
python) cgi script when a form is submitted. It involves running a
bunch of other programs through subprocess in multiple threads and
writing its output in several files. So the only suspicious parts I
can think of is subprocess and/or multithreading. For the
multithreading part I'm using a modified version of threadpool.py
(http://www.chrisarndt.de/en/software...n/threadpool/), which is
built on top of the threading and Queue stdlib modules. Whatever bugs
may linger there, I'd hope that they would show up as normal Python
exceptions instead of segfaults.

All I have now is a few not particularly insightful core files (actual
path names and args changed for privacy):

/home/gsakkis/foo>gdb --core core.20140
GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux".
Core was generated by `python2.5 /home/gsakkis/foo/foo.py --XXX --
max=30 --bar=/tmp/83840`
Program terminated with signal 11, Segmentation fault.
#0 0x080b222d in ?? ()
(gdb) backtrace
#0 0x080b222d in ?? ()
#1 0x080b28d1 in ?? ()
#2 0x080fa8ab in ?? ()
#3 0x0805c918 in ?? ()
(...)
#28 0x080b310f in ?? ()
#29 0x080dbfdd in ?? ()
#30 0x40021fef in ?? ()

Any hints ?

Mar 7 '07 #1
4 2351
If the error is reproducable and you can run wxPython, you could use
the excellent WinPdb debugger, which ships with SPE (python editor):
http://www.digitalpeers.com/pythondebugger/

.... but if you can only run your script on a remote server this won't
help you.

Stani

--
SPE - http://pythonide.stani.be

On 7 Mrz., 20:15, "George Sakkis" <george.sak...@gmail.comwrote:
I have a pure python program (no C extensions) that occasionally core
dumps in a non-reproducible way. The program is started by a (non-
python) cgi script when a form is submitted. It involves running a
bunch of other programs through subprocess in multiple threads and
writing its output in several files. So the only suspicious parts I
can think of is subprocess and/or multithreading. For the
multithreading part I'm using a modified version of threadpool.py
(http://www.chrisarndt.de/en/software...n/threadpool/), which is
built on top of the threading and Queue stdlib modules. Whatever bugs
may linger there, I'd hope that they would show up as normal Python
exceptions instead of segfaults.

All I have now is a few not particularly insightful core files (actual
path names and args changed for privacy):

/home/gsakkis/foo>gdb --core core.20140
GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux".
Core was generated by `python2.5 /home/gsakkis/foo/foo.py --XXX --
max=30 --bar=/tmp/83840`
Program terminated with signal 11, Segmentation fault.
#0 0x080b222d in ?? ()
(gdb) backtrace
#0 0x080b222d in ?? ()
#1 0x080b28d1 in ?? ()
#2 0x080fa8ab in ?? ()
#3 0x0805c918 in ?? ()
(...)
#28 0x080b310f in ?? ()
#29 0x080dbfdd in ?? ()
#30 0x40021fef in ?? ()

Any hints ?

Mar 7 '07 #2
You're using Python on a web server to do something
complicated. You must suffer.

Are you trying to fork off a subprocess in a multithreaded
program? That's unlikely to work. The sematics differ
from OS to OS (Solaris forks all the threads, most other
operating systems don't; most UNIX-based OSs copy all the
open file descriptors, but some give you control of which
open files are passed), and Python may not be thread-safe
in that area.

John Nagle

SPE - Stani's Python Editor wrote:
If the error is reproducable and you can run wxPython, you could use
the excellent WinPdb debugger, which ships with SPE (python editor):
http://www.digitalpeers.com/pythondebugger/

... but if you can only run your script on a remote server this won't
help you.

Stani

--
SPE - http://pythonide.stani.be

On 7 Mrz., 20:15, "George Sakkis" <george.sak...@gmail.comwrote:
>>I have a pure python program (no C extensions) that occasionally core
dumps in a non-reproducible way. The program is started by a (non-
python) cgi script when a form is submitted. It involves running a
bunch of other programs through subprocess in multiple threads and
writing its output in several files. So the only suspicious parts I
can think of is subprocess and/or multithreading. For the
multithreading part I'm using a modified version of threadpool.py
(http://www.chrisarndt.de/en/software...n/threadpool/), which is
built on top of the threading and Queue stdlib modules. Whatever bugs
may linger there, I'd hope that they would show up as normal Python
exceptions instead of segfaults.

All I have now is a few not particularly insightful core files (actual
path names and args changed for privacy):

/home/gsakkis/foo>gdb --core core.20140
GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux".
Core was generated by `python2.5 /home/gsakkis/foo/foo.py --XXX --
max=30 --bar=/tmp/83840`
Program terminated with signal 11, Segmentation fault.
#0 0x080b222d in ?? ()
(gdb) backtrace
#0 0x080b222d in ?? ()
#1 0x080b28d1 in ?? ()
#2 0x080fa8ab in ?? ()
#3 0x0805c918 in ?? ()
(...)
#28 0x080b310f in ?? ()
#29 0x080dbfdd in ?? ()
#30 0x40021fef in ?? ()

Any hints ?


Mar 7 '07 #3
On Mar 7, 4:15 pm, John Nagle <n...@animats.comwrote:
You're using Python on a web server to do something
complicated. You must suffer.

Are you trying to fork off a subprocess in a multithreaded
program? That's unlikely to work. The sematics differ
from OS to OS (Solaris forks all the threads, most other
operating systems don't; most UNIX-based OSs copy all the
open file descriptors, but some give you control of which
open files are passed), and Python may not be thread-safe
in that area.
I see the potential problem in general, but in my case every thread is
exclusively responsible for the subprocesses it forks; no subprocess
is inherited from the main thread or is shared in among the worker
threads.

George

Mar 8 '07 #4
George Sakkis wrote:
On Mar 7, 4:15 pm, John Nagle <n...@animats.comwrote:

> You're using Python on a web server to do something
complicated. You must suffer.

Are you trying to fork off a subprocess in a multithreaded
program? That's unlikely to work. The sematics differ
from OS to OS (Solaris forks all the threads, most other
operating systems don't; most UNIX-based OSs copy all the
open file descriptors, but some give you control of which
open files are passed), and Python may not be thread-safe
in that area.


I see the potential problem in general, but in my case every thread is
exclusively responsible for the subprocesses it forks; no subprocess
is inherited from the main thread or is shared in among the worker
threads.
Forking itself may not be thread safe. Forking is a process-level
operation, for historical reasons.

John Nagle
Mar 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anks | last post by:
i am unable to find why following code is giving segmentation fault.... way to produce seg fault: run the program... give input 12345678....enter any key except 'x'.... again give 12345678 as...
21
by: user | last post by:
I just finish writing LAB2 with no errors when compiling, but once i run it, i get "segmentation fault".. i don't know what is wrong, can anyoen tell me what it means and how i can fix it? thx!
1
by: sysxperts | last post by:
Hello, Having an issue that is specific to PHP compiled with PGSQL support with versions noted in subject line. I understand that there are many variables to consider here but believe I have...
18
by: Digital Puer | last post by:
Hi, I'm coming over from Java to C++, so please bear with me. In C++, is there a way for me to use exceptions to catch segmentation faults (e.g. when I access a location off the end of an array)?...
12
by: Cleverbum | last post by:
Hi, I'm a complete beginner, having written my second program and finally got it to compile, I've got an error I can't track down occurring at runtime - basically whatever I do it says...
4
by: Michael B. Trausch | last post by:
Is there a way to debug scripts that cause segmentation faults? I can do a backtrace in gdb on Python, but that doesn't really help me all that much since, well, it has nothing to do with my...
11
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to...
2
by: Zach | last post by:
I compiled a game client and it crashed (segmentation fault) resulting in a core file being generated. I'm trying to find out exactly what caused it to crash. Any ideas how I can do this with gdb?...
5
by: tshad | last post by:
I am using VS 2005 and find that if I am debugging my program and am still in debug mode, certain functions slow down. For example, if I tracing through some of my code and haven't stopped...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.