Strange crash issue on Windows w/ PyGTK, Cairo...
pez at apocalyptech.com
Wed Mar 18 06:20:21 CET 2009
I'm having a strange issue, and I'm not entirely certain yet where
the actual problem is (ie, Python, PyGTK, or gtk+), but I figure I'll
start here. Bear with me, this'll probably be a long explanation...
I've been building an app which is meant to be run on both Linux and
Windows. It uses PyGTK for its GUI, and the main area of the app is
a gtk.DrawingArea which I draw on using PyCairo. I've been developing
on Linux, and it works great on that platform, with no issues that
I'm aware of. When running on Windows, though, the app exhibits the
1) When the .py of the main file which runs the application GUI first
gets compiled to a .pyc (ie: the first time it's run, or the first
time after .py modification), the application runs totally fine, with
no apparent problems.
2) Any attempt AFTER that, the application will start up, *start* to
do its data-loading, but then almost immediately crash with an
enigmatic "python.exe has generated errors and will be closed by
Windows." When it does so, there is no output whatsoever to the
console that the application was launched from, and the crash doesn't
always happen in exactly the same place.
The pattern remains the same, though - if the .pyc needs to be compiled,
the application works fine, but if not: boom.
I've been steadily stripping the program down to what I hoped would be a
small, reproducible app that I could post here, and I do intend to do so
still, but it's rather slow going. For now, I was hoping to see if
anyone's ever heard of behavior like this before, and might know what
to do about it, or at least a possible avenue of attack.
As I've been reducing the program down, I've encountered even stranger
(IMO) behavior... In one instance, changing a function name seemed to
make the program work. I took out the handler which draws my app's
"About" box, and suddenly my problem went away. Occasionally I would
remove a function and the app would suddenly *always* fail with that
Windows crash error, and I'd have to put the function back in. Keep
in mind, these are functions which *aren't being called anywhere.*
Sometimes I could replace a function's entire contents with just "pass"
and the app would suddenly behave properly, or not behave at all.
It's almost as if whatever's doing the byte-compilation is getting
screwed up somehow, and really small changes to parts of the file which
aren't even being touched are having a huge impact on the application as
a whole. It's seriously vexing, and certainly the oddest problems I've
seen in Python.
Windows versions I can reproduce this on: XP and win2k
Python versions I've reproduced this on:
Python 2.5.4 with:
Python 2.6.1 with:
gtk+ 2.12.9-win32-2 (from http://sf.net/projects/gladewin32 , which is
the version linked to from pygtk.org)
The 2.6 Python stuff I've actually only tried on win2k so far, not XP,
though given my history with this, I suspect that that wouldn't make a
Since gtk+ is the one bit of software that hasn't been swapped out for
another version, I suppose that perhaps that's where the issue is, but
it seems like Python should be able to at least throw an Exception or
something instead of just having a Windows crash. And having it work
the FIRST time, when the .pyc's getting compiled, is rather suspicious.
Anyway, I'll continue trying to pare this app down to one manageable
script which I can post here, but until then I'd be happy to hear ideas
from anyone else about this.
More information about the Python-list