473,722 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2367
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
multithreadin g 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.c omwrote:
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.c omwrote:

> 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
8042
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 input...then segmentation fault happens... please somebody enlighten me... #include <stdio.h> #include<stdlib.h>
21
8294
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
2483
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 narrowed down the Apache Client Cert failures to my PHP/PGSQL build. 1. Apache PHP without PGSQL works as expected using client certificates 2. Apache PHP with PGSQL works fine with standard SSL connections 3 Apache PHP with PGSQL fails with...
18
26111
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)? Thanks.
12
1709
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 Segmentation Fault. I was wondering if there was any way I could get a slightly more verbose description of the error so that I could think about sorting it out. Someone mentioned to me that the g++ option -DRANGE_CHECKING would check if i was accessing...
4
20917
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 script... :-P Any ideas? Thanks, Mike
11
5041
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 debug it let me narrow the problem down to the Cipher function I think it faults at line 84 or 85. The program makes it's first read/cipher/write pass without issue but the second pass kills it. Using gdb to print the variables left showed me the...
2
3702
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? In the Makefile can I just add a "-g" flag to have the binary produced with debugging symbols? The source is written in ANSI C. This is what I have now: "CC = gcc" The client binary is 433680 and the core file produced when it crashed
5
1358
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 debugging and try to open a Windows Explorer window, it will take close to a minute for the window to open up (using the windows/e combination keys). After the window opens, I can open up another window and it will open right away. Until I step to...
0
8860
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.