Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 257550 - dev-python/pyao-0.8.2 crashes with new Python on deallocation
Summary: dev-python/pyao-0.8.2 crashes with new Python on deallocation
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: High critical
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-04 02:51 UTC by gilhad
Modified: 2009-04-23 13:04 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for this bug (pyao-0.82.patch,342 bytes, patch)
2009-02-04 02:52 UTC, gilhad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description gilhad 2009-02-04 02:51:32 UTC
Program using pyao (in Thread, but probabelly everywhere) else crashed or after end emited big dump. It could be hidden by exporting MALLOC_CHECK_="0", but sometimes lead to Segfault too.

All went good, until value returned from ao.AudioDevice() was disposed by Python.

Problem is caused by allocating object by PyObject_NEW(...), but deallocatind by PyMem_DEL(self) where PyObject_FREE(self) should be used.

Did worked in Python < 2.5 (as the DEL and FREE was the same), in Python.2.5 is not longer valid such mixing.





*** glibc detected *** /usr/bin/python: double free or corruption (out): 0xb7bf8110 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7cdea00]
/lib/libc.so.6(cfree+0x89)[0xb7ce06f9]
/usr/lib/python2.5/site-packages/aomodule.so[0xb7f09002]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:03 4523168    /usr/bin/python2.5
08049000-0804a000 r--p 00000000 08:03 4523168    /usr/bin/python2.5


======= Backtrace: =========
/lib/libc.so.6[0xb7cf2a00]
/usr/lib/python2.5/site-packages/aomodule.so[0xb7f1d002]
/usr/lib/libpython2.5.so.1.0(PyString_Type+0x0)[0xb7efa000]


Reproducible: Always

Steps to Reproduce:
1.in Python program use some_var=ao.AudioDevice(...) 
2.exit the scope of some_var (by terminating Thread or the whole Program), so some_var is deallocated by Python
3.see the crash

Actual Results:  
segfault/Abort + Backtrace Dump

Expected Results:  
normal disposing of object

See http://docs.python.org/whatsnew/ports.html for explanation
See http://lists.xensource.com/archives/html/xen-devel/2007-01/msg01362.html for similar problem solved

Solution is really simple and i include a pach for it (but i do not know, how to fix ebuild to accept the patch, so please help)

The patch solves the problem:

diff -ru pyao-0.82/src/aomodule.c pyao-0.82.ok/src/aomodule.c
--- pyao-0.82/src/aomodule.c|---2003-07-24 08:52:59.000000000 +0200
+++ pyao-0.82.ok/src/aomodule.c|2009-02-04 03:22:17.000000000 +0100
@@ -150,7 +150,7 @@
 py_ao_dealloc(ao_Object *self)
 {
   ao_close(self->dev);
-  PyMem_DEL(self);
+  PyObject_FREE(self);
 }
 
 static PyObject *
Comment 1 gilhad 2009-02-04 02:52:46 UTC
Created attachment 180876 [details, diff]
patch for this bug
Comment 2 Patrick Lauer gentoo-dev 2009-04-23 13:04:59 UTC
+  23 Apr 2009; Patrick Lauer <patrick@gentoo.org>                                                                                       
+  +files/pyao-fix-deallocation.patch, +pyao-0.82-r1.ebuild:                                                                             
+  Small fix for >=python-2.5. Thanks to gilhad for the patch. Fixes #257550