473,763 Members | 3,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching a segfault in a Python library

Yo,
An app of mine relies on PIL. When PIL hits a certain problem font (for
unknown reasons as of now) it tends to segfault and no amount of try/except
will keep my wxPython app alive.

My first thought is to start the app from a bash script that will check the
return value of my wxPython app and could then launch a new app to help the
user grok what happened and fix it.

Do you think that's a good idea, or is there another way to handle stuff
like this? (perhaps a Python app launching another Python app?)

/d

Nov 24 '07 #1
14 4959
Donn Ingle <do********@gma il.comwrites:
Do you think that's a good idea, or is there another way to handle stuff
like this? (perhaps a Python app launching another Python app?)
Run your app under a debugger and figure out what is making it crash.
Nov 24 '07 #2
Run your app under a debugger and figure out what is making it crash.
Already done, the code within PIL is causing the crash. It gets ugly and out
of my remit. It's a freetype/Pil thing and I simply want to a way to catch
it when it happens.
Since a segfault ends the process, I am asking about "wrappers" around code
to catch a segfault.

\d

Nov 24 '07 #3
Donn Ingle <do********@gma il.comwrites:
Run your app under a debugger and figure out what is making it crash.
Already done, the code within PIL is causing the crash. It gets ugly and out
of my remit. It's a freetype/Pil thing and I simply want to a way to catch
it when it happens.
Since a segfault ends the process, I am asking about "wrappers" around code
to catch a segfault.
Well I think you should actually debug it, or at least reproduce it
and send a bug report to the PIL folks, but anyway you can use
os.wait() to get the exit status and recognize the seg fault.
Nov 24 '07 #4
Well I think you should actually debug it, or at least reproduce it
and send a bug report to the PIL folks,
It was a while ago, and if memory serves I did that, but memory fails.
but anyway you can use
os.wait() to get the exit status and recognize the seg fault.
Okay, that's a good start. Thanks, I'll go for a python starts wxpython
thing with os.wait() to sniff the outcome.
\d

Nov 24 '07 #5
Donn Ingle <do********@gma il.comwrites:
Okay, that's a good start. Thanks, I'll go for a python starts wxpython
thing with os.wait() to sniff the outcome.
You may have to roll your own fork/exec to start the wxpython, instead
of using popen or the subprocess module. I'm not terribly conversant
in those modules but they may start a shell which would isolate your
program from the wxpython exit code.
Nov 24 '07 #6
You may have to roll your own fork/exec to start the wxpython, instead
of using popen or the subprocess module. Â*I'm not terribly conversant
in those modules but they may start a shell which would isolate your
program from the wxpython exit code.
Hrmm... Neither am I, that's why I asked here :) But I'll skin that Python
when I get to it.

Thanks.
\d

Nov 24 '07 #7
Donn Ingle wrote:
Already done, the code within PIL is causing the crash. It gets ugly and
out of my remit. It's a freetype/Pil thing and I simply want to a way to
catch it when it happens.
Since a segfault ends the process, I am asking about "wrappers" around
code
to catch a segfault.

\d
Wouldn't it be better to narrow down to what in your code is invoking PIL
in a manner in which PIL exhibits such behaviour, and handle it within
your code?

Just a thought!

--
Ayaz Ahmed Khan
Nov 24 '07 #8
On 24 Nov 2007 08:41:24 GMT, Ayaz Ahmed Khan <ay**@dev.nullw rote:
Donn Ingle wrote:
Already done, the code within PIL is causing the crash. It gets ugly and
out of my remit. It's a freetype/Pil thing and I simply want to a way to
catch it when it happens.
Since a segfault ends the process, I am asking about "wrappers" around
code
to catch a segfault.

\d

Wouldn't it be better to narrow down to what in your code is invoking PIL
in a manner in which PIL exhibits such behaviour, and handle it within
your code?

Just a thought!

--
Ayaz Ahmed Khan

--
http://mail.python.org/mailman/listinfo/python-list
I think the idea is, certain fonts in his collection may be corrupt,
and he wants to just scan through and load them, ignoring the ones
that make the program crash. The bug in this case lies with a third
party and isn't something he can easily fix (although he can file
reports to the third party (PIL)).

This has come up for me as well with loading meshes in a 3d
application. The user or someone may include a corrupt file, and it's
not nice for the application to just crash when that happens, asking
them if they want to debug it. I haven't really found a solution,
just have tried to prevent corrupted files in the system for now. Let
me know if you get this solved :)
Nov 24 '07 #9
I think the idea is, certain fonts in his collection may be corrupt,
and he wants to just scan through and load them, ignoring the ones
that make the program crash. Â*
Ya got me! Sheesh, I can't hide anywhere :D
The bug in this case lies with a third
party and isn't something he can easily fix (although he can file
reports to the third party (PIL)).
I've a bad memory and can't recall what I told PIL at the time. It might
have been a case of waiting to see what new versions can do.
not nice for the application to just crash when that happens, asking
them if they want to debug it. Â*
Zigactly! You can wrap try/except around the calls that (by debugging) you
know are the culprits, but a segfault is a segfault and bam! you are at the
command line again.
I haven't really found a solution,
just have tried to prevent corrupted files in the system for now. Â*Let
me know if you get this solved
I'll certainly pop a note. I think, though, that the answer may reside in
the basic theme of this thread:

runapp
result = runActualApp( )
while True:
if result == allokay: break
else:
<Start handling the horror>

Unless a segfault goes through that too, like Krypton through Superman.
\d

Nov 24 '07 #10

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

Similar topics

2
4989
by: Olli Piepponen | last post by:
Hi, I'm having a little problem catching keystrokes under Windows. I did a little research and found that with mscvrt.getch() one can cath a single key that is pressed. However this doesn't work when the program is run on the backround and not as the primary task. What I would like to have is a same sort of function that would also work when the program is being run on the background. I'm trying to implement a program that would listen...
12
3161
by: Nathaniel Echols | last post by:
I've written a function in C to perform protein sequence alignment. This works fine in a standalone C program. I've added the necessary packaging to use it in Python; it returns three strings and an integer. However, as soon as the function is complete, I get a segfault and the interpreter dies. If I run Python interactively, just calling the function causes a segfault. If I'm running a script, I can actually print out the return...
6
3018
by: Juho Saarikko | last post by:
The program attached to this message makes the Python interpreter segfault randomly. I have tried both Python 2.2 which came with Debian Stable, and self-compiled Python 2.3.3 (newest I could find on www.python.org, compiled with default options (./configure && make). I'm using the pyPgSQL plugin to connect to a PostGreSQL database, and have tried the Debian and self-compiled newest versions of that as well. I'm running BitTorrent, and...
6
1986
by: Stefan Behnel | last post by:
Hi! In Python 2.4b3, the deque is causing a segfault on two different machines I tested on. With deque, my program runs fine for a while (at least some tens of seconds up to minutes) and then suddenly segfaults. I'm sorry I can't tell exactly when, but I'm running an application that uses a few hundred deques where elements are appendleft()ed and pop()ed (simple queue). As the application is rather complex (and I didn't read about this...
0
1821
by: dale | last post by:
Python newbie disclaimer on I am running an app with Tkinter screen in one thread and command-line input in another thread using raw_input(). First question - is this legal, should it run without issue? If not can you point me to a description of why. While updating objects on the screen I get a segfault after an indeterminate number of updates. It doesn't seem to matter how quickly the updates occur, but it does segfault faster...
0
1433
by: nirnimesh | last post by:
I'm intercepting a library function call using LD_PRELOAD and in-turn calling the orignial library function. Essentially, intercept.cc: void (*real_func)(void) = (void (*) (void)) dlsym(RTLD_NEXT, "_mangled_name_of_func_"); real_func(); //! Calling the original function -- SEGFAULT This is compiled as: g++ -shared -fPIC -Wall -o libintercept.so intercept.cc -ldl
4
1883
by: klappnase | last post by:
Hello, I use the tktreectrl Tk extension (http://tktreectrl.sourceforge.net) through the python wrapper module (http://klappnase.zexxo.net/TkinterTreectrl/index.html). With python-2.5 it seems that each time some text is inserted into the treectrl widget a segfault occurs (on linux, on windows2000 it seemed to work). Some people sent me mail describing the same problem, so I think it is not a problem with my installation of python-2.5....
0
1066
by: bernhard.voigt | last post by:
Dear list, I'm using two external modules (matplotlib and pyroot). Both are using different GUI threads (internally) Unfortunately, pretty soon after I've loaded both modules and made some function calls (without invoking GUI commands), python dies with a segfault. A libthread_db captures the stack trace. My python version is 2.5 and I'm on a Scientific Linux 5 system. *** Break *** segmentation violation
3
1949
by: Paul Sijben | last post by:
I am running a multi-threaded python application in a dual core intel running Ubuntu. I am using python 2.5.1 that I compiled myself. At random points I am getting segmentation faults (sometimes indicating a duplicate free). Below is the backtrace of the latest segfault. I am thinking this might be an issue related to the dual core CPU so I am now running the app with affinity to one CPU to test this hypothesis.
0
9566
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
10003
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...
1
9943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9828
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
8825
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
7370
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
5271
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
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

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.