[cairo] PyCairo - Crash on Windows build, in either zlib or PyCairo

Steve stevech1097 at yahoo.com.au
Fri Mar 20 20:44:46 PDT 2009


On Fri, 2009-03-20 at 12:00 -0700, cairo-request at cairographics.org
wrote:
> Hello list!
> 
> I've been developing an app in Python which uses PyCairo, which is
> meant
> to be cross-platform.  I've been developing on Linux, and when testing
> on Windows, I started having really bizarre problems with crashing,
> with
> a generic "python.exe has generated errors and will be closed by
> Windows" 
> message.  I'll spare you the details of tracking it down, but in the
> end
> it can boil down to a very short script which I've put up here:
> 
> http://apocalyptech.com/pygtk-zlib/
> 
> I'm not yet sure if the problem is in Python's builtin zlib functions,
> or in PyCairo's ImageSurface.create_from_png().  When I'm
> decompressing
> zlib-based data and I *don't* specify bufsize, the cairo call in there
> will end up generating a crash.  If I *do* specify an appropriate
> bufsize, then the call to Cairo ends up working just fine. [1]
> 
> Since it's in the Cairo call that the program actually crashes, Cairo
> is
> certainly a suspect there, but I can't help but think that perhaps
> zlib
> is at fault...  Python's documentation mentions malloc() behavior in
> the
> zlib.decompress() reference, which makes me think that perhaps it's
> clobbering memory where it shouldn't, and the Cairo call just happens
> to
> run up against the area of memory that's been clobbered.
> 
> That having been said, though, I haven't yet been able to reproduce
> the
> problem with anything other than that create_from_png() call.
> 
> So anyway, I'm hoping more eyes will help get this figured out.  I've
> got a list of software versions that I've been able to reproduce this
> with at the above URL, but here it is for completeness' sake:
> 
> Windows versions: XP and win2k
> Python versions:
>   Python 2.5.4 with:
>     PyGTK 2.12.1-2-win32-py2.5
>     PyGObject 2.14.1-1.win32-py2.5
>     PyCairo 1.4.12-1.win32-py2.5
>   Python 2.6.1 with:
>     PyGTK 2.12.1-3-win32-py2.6
>     PyGObject 2.14.2-2.win32-py2.6
>     PyCairo 1.4.12-2.win32-py2.6
> GTK versions used:
>   gtk+ 2.12.9-win32-2 from the gladewin32 project
>   gtk+-bundle 2.16.0-20090317_win32, from the other link on pygtk's
>   download page

The PyGTK, PyGObject and GTK versions are not relevant since they are
not used in the test case.

I took a look at the '_read_func' in pycairo-surface.c and updated it to
fix what might possibly be a couple of problems. But its hard to know if
it fixed this problem since the test case worked OK on Linux before and
it works OK on Linux after the changes.

PyCairo 1.4.12 is over a year old and the problem may not exist in newer
versions of PyCairo and cairo. I suggest:
1. Retesting with Python 2.6, PyCairo 1.8.4 and cairo 1.8.4 to confirm
the problem still exists.
2. Retest with PyCairo from CVS to see if the changes I made fix the
problem.


> Somewhat notably, PyCairo is one of the few components that I've not
> had the opportunity to try multiple versions on, really.  The Python
> 2.5
> and Python 2.6 versions are, I'm sure, almost identical.
> 
> I mention it on the page, but I'll mention it here once more: in
> Linux,
> this problem simply doesn't happen.  It's just a problem with the
> Windows builds.
> 
> Thanks, and apologies for the long-winded post!
> 
> -CJ
> 
> [1] At least it does for this test app.  When I plugged in that fix to
> my larger app, I found that I did eventually experience the same
> crashing problem, though far less often (enough so that the app is at
> least usable on Windows).  So specifying a bufsize doesn't completely
> alleviate the problem.
> 
Steve




More information about the cairo mailing list