PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 693 - Heap corruption or double free reported on program exit
: Heap corruption or double free reported on program exit
Status: CLOSED WORKSFORME
Product: PySide
Classification: Unclassified
Component: PySide
: HEAD
: PC Linux
: P2 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-02-21 14:57 EET by Vinay Sajip
Modified: 2011-06-22 20:25 EEST (History)
9 users (show)

See Also:


Attachments
Program to send log events to logview, the program which crashes (7.46 KB, text/plain)
2011-02-21 14:57 EET, Vinay Sajip
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vinay Sajip 2011-02-21 14:57:56 EET
Created attachment 272 [details]
Program to send log events to logview, the program which crashes

I'm getting an error when my application exits.

The application is called logview and is available at

http://code.google.com/p/logview/

The source code archive is at

http://logview.googlecode.com/files/logview-src-0.1.tar.gz

If you download this archive (which is for use with PyQt4) and replace qt.py
with:

from PySide import QtCore, QtGui, __version__ as PYQT_VERSION_STR
QT_VERSION_STR = QtCore.__version__
WRAPPER = 'PySide'
Qt = QtCore.Qt

Then you should be able to reproduce this error. If you run "python logview.py"
and then run the attached script "genlog.py" which sends some events to
logview, and then close logview, you get the error:

Traceback (most recent call last):
  File "logview.py", line 675, in closeEvent
    self.save_settings()
  File "logview.py", line 659, in save_settings
    self.save_colors(self.lmodel.background_map, 'records/background')
  File "logview.py", line 621, in save_colors
    v = ','.join([str(i) for i in mapping[k].getRgb()])
RuntimeError: Internal C++ object (PySide.QtGui.QColor) already deleted.

When the program is packaged with PyInstaller and run, some more detailed  info
is printed, which may be useful for diagnosing the problem:

Traceback (most recent call last):
  File "<string>", line 675, in closeEvent
  File "<string>", line 659, in save_settings
  File "<string>", line 621, in save_colors
RuntimeError: Internal C++ object (PySide.QtGui.QColor) already deleted.
*** glibc detected *** dist/logview/logview: double free or corruption
(fasttop): 0x08625748 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb760eb25]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7612590]
dist/logview/libstdc++.so.6(_ZdlPv+0x21)[0xb6d1cb11]
dist/logview/libshiboken-python2.5.so.1.0[0xb7347f26]
dist/logview/libshiboken-python2.5.so.1.0(_ZN8Shiboken6Object7destroyEP9SbkObjectPv+0x4e)[0xb7348164]
dist/logview/libshiboken-python2.5.so.1.0(_ZN8Shiboken14BindingManagerD1Ev+0x44)[0xb734bae2]
dist/logview/libshiboken-python2.5.so.1.0[0xb734bb2a]
/lib/tls/i686/cmov/libc.so.6(exit+0xd4)[0xb75d1084]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe8)[0xb75b9458]
dist/logview/logview[0x8049071]
======= Memory map: ========
08048000-0804d000 r-xp 08048000 00:00 0 
0804d000-0874b000 rwxp 0804d000 00:00 0          [heap]
b292f000-b2930000 ---p b292f000 00:00 0 
b2930000-b3130000 rwxp b2930000 00:00 0 
b3130000-b3131000 ---p b3130000 00:00 0 
b3131000-b3931000 rwxp b3131000 00:00 0 
b3931000-b393a000 r-xp 00000000 08:01 1909801   
/lib/tls/i686/cmov/libnss_files-2.7.so
b393a000-b393c000 rwxp 00008000 08:01 1909801   
/lib/tls/i686/cmov/libnss_files-2.7.so
b3940000-b3947000 r-xp 00000000 08:01 1613846   
/home/vinay/.virtualenvs/default/plugins/imageformats/libqico.so
b3947000-b3948000 rwxp 00006000 08:01 1613846   
/home/vinay/.virtualenvs/default/plugins/imageformats/libqico.so
b3948000-b3949000 ---p b3948000 00:00 0 
b3949000-b4149000 rwxp b3949000 00:00 0 
b4149000-b414a000 ---p b4149000 00:00 0 
b414a000-b494a000 rwxp b414a000 00:00 0 
b494a000-b494b000 ---p b494a000 00:00 0 
b494b000-b514b000 rwxp b494b000 00:00 0 
b514b000-b51d2000 r-xp 00000000 08:01 189881    
/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf
b51d2000-b5263000 r-xp 00000000 08:01 189882    
/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
b5263000-b526b000 r-xp 00000000 08:01 50489      /usr/lib/libXcursor.so.1.0.2
b526b000-b526c000 rwxp 00007000 08:01 50489      /usr/lib/libXcursor.so.1.0.2
b5270000-b5277000 r-xp 00000000 08:01 1591186   
/home/vinay/projects/logview/dist/logview/libXi.so
b5277000-b5278000 rwxp 00006000 08:01 1591186   
/home/vinay/projects/logview/dist/logview/libXi.so
b5278000-b527d000 r-xp 00000000 08:01 50517      /usr/lib/libXrandr.so.2.1.0
b527d000-b527e000 rwxp 00005000 08:01 50517      /usr/lib/libXrandr.so.2.1.0
b5284000-b5288000 r-xp 00000000 08:01 50499      /usr/lib/libXfixes.so.3.1.0
b5288000-b5289000 rwxp 00003000 08:01 50499      /usr/lib/libXfixes.so.3.1.0
b5289000-b528a000 r-xp 00000000 08:01 304647    
/usr/share/locale-langpack/en_GB/LC_MESSAGES/libc.mo
b528a000-b5290000 r-xs 00000000 08:01 1343558   
/var/cache/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-x86.cache-2
b5290000-b5293000 r-xs 00000000 08:01 1344107   
/var/cache/fontconfig/e383d7ea5fbe662a33d9b44caf393297-x86.cache-2
b5293000-b5294000 r-xs 00000000 08:01 1344106   
/var/cache/fontconfig/c69f04ab05004e31a6d5e715764f16d8-x86.cache-2
b5294000-b5295000 r-xs 00000000 08:01 1344105   
/var/cache/fontconfig/4c73fe0c47614734b17d736dbde7580a-x86.cache-2
b5295000-b5298000 r-xs 00000000 08:01 1344104   
/var/cache/fontconfig/a755afe4a08bf5b97852ceb7400b47bc-x86.cache-2
b5298000-b529b000 r-xs 00000000 08:01 1344103   
/var/cache/fontconfig/6d41288fd70b0be22e8c3a91e032eec0-x86.cache-2
b529b000-b529e000 r-xs 00000000 08:01 1344102   
/var/cache/fontconfig/de156ccd2eddbdc19d37a45b8b2aac9c-x86.cache-2
b529e000-b52a6000 r-xs 00000000 08:01 1344101   
/var/cache/fontconfig/e3de0de479f42330eadf588a55fb5bf4-x86.cache-2
b52a6000-b52ae000 r-xs 00000000 08:01 1344100   
/var/cache/fontconfig/0f34bcd4b6ee430af32735b75db7f02b-x86.cache-2
b52ae000-b52af000 r-xs 00000000 08:01 1344099   
/var/cache/fontconfig/4794a0821666d79190d59a36cb4f44b5-x86.cache-2
b52af000-b52b2000 r-xs 00000000 08:01 1344098   
/var/cache/fontconfig/de9486f0b47a4d768a594cb4198cb1c6-x86.cache-2
b52b2000-b52b9000 r-xs 00000000 08:01 1344097   
/var/cache/fontconfig/d52a8644073d54c13679302ca1180695-x86.cache-2
b52b9000-b52bf000 r-xs 00000000 08:01 1343551   
/var/cache/fontconfig/089dead882dea3570ffc31a9898cfb69-x86.cache-2
b52bf000-b52c1000 r-xs 00000000 08:01 1343564   
/var/cache/fontconfig/e13b20fdb08344e0e664864cc2ede53d-x86.cache-2
b52c1000-b52c3000 r-xp 00000000 08:01 67949      /usr/lib/gconv/UTF-16.so
b52c3000-b52c5000 rwxp 00001000 08:01 67949      /usr/lib/gconv/UTF-16.so
b52c5000-b52c6000 r-xp 00000000 08:01 82745     
/usr/lib/locale/en_GB.utf8/LC_NUMERIC
b52c6000-b52c7000 r-xp 00000000 08:01 82748     
/usr/lib/locale/en_GB.utf8/LC_TIME
b52c7000-b53a8000 r-xp 00000000 08:01 82739     
/usr/lib/locale/en_GB.utf8/LC_COLLATE
b53a8000-b53a9000 r-xp 00000000 08:01 82743     
/usr/lib/locale/en_GB.utf8/LC_MONETARY
b53a9000-b53aa000 r-xp 00000000 08:01 82749     
/usr/lib/locale/en_GB.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b53aa000-b53ab000 r-xp 00000000 08:01 82746     
/usr/lib/locale/en_GB.utf8/LC_PAPER
b53ab000-b53ac000 r-xp 00000000 08:01 82744     
/usr/lib/locale/en_GB.utf8/LC_NAME
b53ac000-b53ad000 r-xp 00000000 08:01 82738     
/usr/lib/locale/en_GB.utf8/LC_ADDRESS
b53ad000-b53b2000 r-xp 00000000 08:01 1591148   
/home/vinay/projects/logview/dist/logview/operator.so
b53b2000-b53b3000 rwxp 00005000 08:01 1591148   
/home/vinay/projects/logview/dist/logview/operator.so
b53b3000-b53b6000 r-xp 00000000 08:01 1591126   
/home/vinay/projects/logview/dist/logview/_locale.so
b53b6000-b53b7000 rwxp 00003000 08:01 1591126   
/home/vinay/projects/logview/dist/logview/_locale.so
b53b7000-b53bd000 r-xp 00000000 08:01 1591111   
/home/vinay/projects/logview/dist/logview/zmq.devices.monitoredqueue.so
b53bd000-b53be000 rwxp 00006000 08:01 1591111   
/home/vinay/projects/logview/dist/logview/zmq.devices.monitoredqueue.so
b53be000-b53c1000 r-xp 00000000 08:01 1591124   
/home/vinay/projects/logview/dist/logview/zmq.core.device.so
b53c1000-b53c2000 rwxp 00002000 08:01 1591124   
/home/vinay/projects/logview/dist/logview/zmq.core.device.so
b53c2000-b53c4000 r-xp 00000000 08:01 1591137   
/home/vinay/projects/logview/dist/logview/zmq.core.version.so
b53c4000-b53c5000 rwxp 00002000 08:01 1591137   
/home/vinay/projects/logview/dist/logview/zmq.core.version.so
b53c5000-b53c8000 r-xp 00000000 08:01 1591144   
/home/vinay/projects/logview/dist/logview/zmq.core.stopwatch.so
b53c8000-b53c9000 rwxp 00003000 08:01 1591144   
/home/vinay/projects/logview/dist/logview/zmq.core.stopwatch.so
b53c9000-b53d4000 r-xp 00000000 08:01 1591109   
/home/vinay/projects/logview/dist/logview/zmq.core.poll.so
b53d4000-b53d6000 rwxp 0000b000 08:01 1591109   
/home/vinay/projects/logview/dist/logview/zmq.core.poll.so
b53d6000-b53d8000 r-xp 00000000 08:01 1591153   
/home/vinay/projects/logview/dist/logview/_random.so
b53d8000-b53d9000 rwxp 00002000 08:01 1591153   
/home/vinay/projects/logview/dist/logview/_random.so
b53d9000-b53dc000 r-xp 00000000 08:01 1591125   
/home/vinay/projects/logview/dist/logview/math.so
b53dc000-b53dd000 rwxp 00002000 08:01 1591125   
/home/vinay/projects/logview/dist/logview/math.so
b53dd000-b53f5000 r-xp 00000000 08:01 1591145   
/home/vinay/projects/logview/dist/logview/zmq.core.socket.so
b53f5000-b53fa000 rwxp 00018000 08:01 1591145   
/home/vinay/projects/logview/dist/logview/zmq.core.socket.so
b53fa000-b53ff000 r-xp 00000000 08:01 1591135   
/home/vinay/projects/logview/dist/logview/zmq.core.context.so
b53ff000-b5400000 rwxp 00005000 08:01 1591135   
/home/vinay/projects/logview/dist/logview/zmq.core.context.so
b5400000-b540c000 r-xp 00000000 08:01 1591146   
/home/vinay/projects/logview/dist/logview/zmq.core.message.so
b540c000-b540e000 rwxp 0000b000 08:01 1591146   
/home/vinay/projects/logview/dist/logview/zmq.core.message.so
b540e000-b5412000 r-xp 00000000 08:01 1591121   
/home/vinay/projects/logview/dist/logview/zmq.core.error.so
b5412000-b5413000 rwxp 00004000 08:01 1591121    /home/

[output truncated presumably due to process exit]

Note: No error is reported with PyQt4.
Comment 1 Vinay Sajip 2011-02-21 15:10:54 EET
Error occurs on Ubuntu Jaunty (Python 2.5.2)
Comment 2 Hugo Parente Lima 2011-02-21 15:16:21 EET
Thanks for the detailed report.
Comment 3 Hugo Parente Lima 2011-03-17 22:34:11 EET
Do you have a reduced example showing the problem? because it's a bit hard and
very time consuming reduce the code of your program until find the causes of
the bug.
Comment 4 Vinay Sajip 2011-03-18 10:12:33 EET
Sorry I couldn't be more helpful. I don't have a reduced example (otherwise I'd
have posted it). I tried to create a really minimal example with just colours,
but I was unable to reproduce the error with that. Can't you just set a C/C++
breakpoint when the colour gets deleted? Since my code never explicitly frees
the colours, it presumably happens during program exit.

Of course if I can come up with a minimal example, I'll attach it. However, I
unfortunately don't have a lot of time to look at it right now, especially as
it's an open-ended activity with no guarantee of success :-(
Comment 5 Hugo Parente Lima 2011-03-18 15:54:09 EET
Don't worry, I did already found the problem and am working to fix it.
Comment 6 Hugo Parente Lima 2011-03-18 15:56:17 EET
Ah, BTW the problem is on data() method of QAbstractItemModel that always set
the ownership of the returned object to C++, but it can't do it when the
returned type is a "value type" like QColor.
Comment 7 Hugo Parente Lima 2011-03-18 23:43:17 EET
Fixed in commit:
shiboken/caec0092e785137612f441f3ea3e7142da95ae8e

Unit test in commit:
pyside/13d9f714c5a990ff22b2e1621e1706ed81a1846b
Comment 8 Hugo Parente Lima 2011-04-01 23:16:09 EEST
Closing bug after release of PySide 1.0.1.
Comment 9 Markus Ullmann 2011-05-07 11:49:40 EEST
Just came up in 1.0.2 again for me on OS X / Apple Python 2.6
Comment 10 Markus Ullmann 2011-05-07 13:46:19 EEST
Actually it didn't run the build tree version but the installed... :/
Comment 11 renato filho 2011-06-22 20:25:22 EEST
release 1.0.4