Bug 360151

Summary: Frequent segfault when a PyQt application exits.
Product: [Plasma] Breeze Reporter: Antony Lee <anntzer.lee>
Component: QStyleAssignee: Hugo Pereira Da Costa <hugo.pereira.da.costa>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bhush94, hugo.pereira.da.costa, plasma-bugs
Priority: NOR    
Version: 5.5.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Antony Lee 2016-03-06 06:21:31 UTC
At the exit of various PyQt5 scripts, python segfaults fairly frequently.  This is *not* (solely, at least) a PyQt related issue, as I cannot reproduce it when using an XFCE session, and the PyQt main developer cannot reproduce it on MacOS (https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037011.html).

Reproducible: Always

Steps to Reproduce:
Run the following Python script (PyQt 5.5.1, python2 or python3):
```
from PyQt5.QtWidgets import *
class Main(QMainWindow):
    def fail(self):
        QInputDialog.getItem(self, "foo", "bar", ["baz"])
        raise Exception
app = QApplication([])
main = Main()
main.fail()
app.exec_()
```

Actual Results:  
After selecting a value and raising a (normal) exception, the application segfaults (not always, but more than half of the time).

Expected Results:  
The application should exit with status 1 (failed with exception).

a gdb backtrace (without any debug informations, sorry):
```
(gdb) bt
#0  0x00007ffff505c01b in ?? () from /usr/lib/libQt5Core.so.5
#1  0x00007ffff505b29b in QPropertyAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State) () from /usr/lib/libQt5Core.so.5
#2  0x00007ffff5053679 in QAbstractAnimation::stop() () from /usr/lib/libQt5Core.so.5
#3  0x00007ffff505a387 in QPropertyAnimation::~QPropertyAnimation() () from /usr/lib/libQt5Core.so.5
#4  0x00007fffdd8118b3 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#5  0x00007ffff528884b in QObjectPrivate::deleteChildren() () from /usr/lib/libQt5Core.so.5
#6  0x00007ffff52925d0 in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#7  0x00007fffdd812913 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#8  0x00007ffff528884b in QObjectPrivate::deleteChildren() () from /usr/lib/libQt5Core.so.5
#9  0x00007ffff52925d0 in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#10 0x00007fffdd813179 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#11 0x00007ffff528884b in QObjectPrivate::deleteChildren() () from /usr/lib/libQt5Core.so.5
#12 0x00007ffff52925d0 in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#13 0x00007fffdd812a50 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#14 0x00007ffff528884b in QObjectPrivate::deleteChildren() () from /usr/lib/libQt5Core.so.5
#15 0x00007ffff52925d0 in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#16 0x00007fffdd7eb0e9 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#17 0x00007ffff528a1a7 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/libQt5Core.so.5
#18 0x00007ffff528abbf in QObject::destroyed(QObject*) () from /usr/lib/libQt5Core.so.5
#19 0x00007ffff529214a in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#20 0x00007fffdd802b57 in ?? () from /usr/lib/qt/plugins/styles/breeze.so
#21 0x00007ffff5250235 in ?? () from /usr/lib/libQt5Core.so.5
#22 0x00007ffff5248732 in ?? () from /usr/lib/libQt5Core.so.5
#23 0x00007ffff5248959 in ?? () from /usr/lib/libQt5Core.so.5
#24 0x00007ffff5292618 in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#25 0x00007ffff52478c0 in QFactoryLoader::~QFactoryLoader() () from /usr/lib/libQt5Core.so.5
#26 0x00007ffff5bb8439 in ?? () from /usr/lib/libQt5Widgets.so.5
#27 0x00007ffff7382c38 in __run_exit_handlers () from /usr/lib/libc.so.6
#28 0x00007ffff7382c85 in exit () from /usr/lib/libc.so.6
#29 0x00007ffff736d717 in __libc_start_main () from /usr/lib/libc.so.6
#30 0x0000000000400b99 in _start ()
```

This occurs both with the breeze and oxygen themes (which I tried as they are mentioned in the backtrace), but not under XFCE.
Comment 1 Rex Dieter 2016-03-06 06:27:14 UTC
triaging to breeze (qt5) theme
Comment 2 Hugo Pereira Da Costa 2016-03-07 19:59:43 UTC
So ... 
Something wrong in the destruction chain
most likely upstream (qt) since we (breeze/oxygen) don't take care of destruction ourselves ...
Comment 3 Antony Lee 2016-03-07 21:38:05 UTC
If this was the case, the bug would certainly also occur when running another DE, e.g. XFCE?
Comment 4 Rex Dieter 2016-03-08 03:43:00 UTC
Fwiw, I cannot reproduce on fedora 23 (x86_64), with plasma-5.5.5/PyQt-5.5.1/Qt-5.6.0-rc (tried 6 times, 3 with python2, 3 with python3)
Comment 5 Hugo Pereira Da Costa 2016-03-08 07:40:22 UTC
(In reply to Antony Lee from comment #3)
> If this was the case, the bug would certainly also occur when running
> another DE, e.g. XFCE?

If also using the breeze theme, (or the oxygen theme), yes.
And that would also be the case if the bug were in either breeze or oxygen, and not upstream in Qt.

Note that the bug being in the Qt deletion chain does not mean that it should happen for all widget styles: it probably require a specific set of qwidgets/qobjects/signal/slots to be triggered, which unfortunately both breeze and oxygen trigger (whether they do things correctly or not).
Comment 6 Hugo Pereira Da Costa 2016-03-14 11:35:27 UTC

*** This bug has been marked as a duplicate of bug 356940 ***