Bug 19287 - Threading support results in crashes in cairo.ImageSurface.{create_from_png,write_to_png}
Summary: Threading support results in crashes in cairo.ImageSurface.{create_from_png,w...
Status: RESOLVED FIXED
Alias: None
Product: pycairo
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Steve Chaplin
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-25 18:15 UTC by Allan McRae
Modified: 2009-02-16 05:12 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Allan McRae 2008-12-25 18:15:21 UTC
pycario-1.8.0 causes pychess and gpodder to crash.  Tracing the cause of the problem, locates the issue to the cairo.ImageSurface.{create_from_png,write_to_png} functions.  Removing the threading support around the line which causes the segfault in these functions fixes the issue.

Environment:
  Arch Linux
  python-2.6.1
  cairo-1.8.6
  pycairo-1.8.0


pychess:
Line that segfaults
  self.surface = cairo.ImageSurface.create_from_png(f)

Pycario function offending line
  static PyObject *
  image_surface_create_from_png (PyTypeObject *type, PyObject *file)
  {
  <snip>
      Py_BEGIN_ALLOW_THREADS
      is = cairo_image_surface_create_from_png_stream (_read_func, file);
      Py_END_ALLOW_THREADS
  ...

gpodder:
Line that segfaults
    s.write_to_png(sio)

Pycario function offending line
  static PyObject *
  surface_write_to_png (PycairoSurface *o, PyObject *file)
  {
  <snip>
	Py_BEGIN_ALLOW_THREADS
	status = cairo_surface_write_to_png_stream (o->surface, _write_func,
						    file);
  	Py_END_ALLOW_THREADS
  ...
Comment 1 Thomas Perl 2008-12-28 12:12:19 UTC
Seems to be a result of the changes from bug 18101.
Comment 2 Thomas Perl 2008-12-28 12:13:30 UTC
I don't feel entitled to change the severity of this bug, but as it crashes gPodder on Arch Linux, I think the severity should be increased.

Crashing apps make users unhappy.
Comment 3 Steve Chaplin 2008-12-29 16:07:24 UTC
Allan,
Could you provide the sequence of instructions for running pychess and gpodder which demonstrates where the code segfaults.

I tried running gpodder and get the message
*** glibc detected *** /a/bin/python: malloc(): memory corruption: 0x00007f37fdee2460 ***
But I don't see pycairo mentioned at all.
Comment 4 Allan McRae 2008-12-29 17:47:19 UTC
pychess crashes during initialisation.  I can get gpodder to crash by double clicking on a feed and clicking download.
Comment 5 Steve Chaplin 2008-12-31 22:20:47 UTC
I've removed the ALLOW_THREADS wrappers for the cairo stream functions. But
when running gpodder I still get Bug Buddy popping up, and generating a file
containing a long backtrace, none of which mentions pycairo.

It would be good if a few people could test the latest pycairo code from cvs
and report back whether or not it fixes the problem.
Comment 6 Allan McRae 2008-12-31 22:32:01 UTC
pycairo from cvs fixes both gpodder and pychess for me.  No idea what is causing your gpodder crash.
Comment 7 Steve Chaplin 2009-01-15 02:53:50 UTC
pycairo 1.8.2 has been released with the fixes made for this bug report.
Comment 8 Steve Chaplin 2009-02-16 05:12:19 UTC
I've undone the changes made on 2008-12-31 and restored ALLOW_THREADS wrappers for the cairo stream functions. (It never was a proper bug fix, it just hid the problem by avoiding the bug). I've added PyGILState_Ensure/PyGILState_Release around calls to the Python C API - this should fix the problem.
I've not tested pychess or gpodder since I do not have all the required libraries correctly installed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.