Catching a segfault in a Python library

Patrick Mullen saluk64007 at gmail.com
Sat Nov 24 03:58:35 EST 2007


On 24 Nov 2007 08:41:24 GMT, Ayaz Ahmed Khan <ayaz at dev.null> wrote:
> 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 :)



More information about the Python-list mailing list