[Python-modules-team] Bug#935909: python3-pyqt5: Segmentation fault when switching between image and text with html tags using style sheets
Danny Milosavljevic
danny.milo at gmail.com
Tue Aug 27 17:06:07 BST 2019
Package: python3-pyqt5
Version: 5.11.3+dfsg-1+b3
Severity: important
Dear Maintainer,
there is a segmentation fault problem with python3-qt5 and/or qt5 when switching between image and text with html tags.
To reproduce,
(1) Use Debian 10 live iso (or any Debian 10; it happened on a finished installation as well)
(2) Invoke: sudo apt-get update
(3) Invoke: sudo apt-get install python3-pyqt5
(4) Invoke: cp /usr/share/icons/Adwaita/48x48/status/network-wired-disconnected.png .
(or any other png)
(5) Save the text below as "a.py"
(6) Invoke: QT_QPA_PLATFORM=offscreen python3 a.py 1
(7) Wait for 5 seconds
(8) See the segmentation fault
It's very very reproducible for me.
Text:
from PyQt5.QtWidgets import QWidget, QLabel, QApplication
from PyQt5.QtCore import QTimer, QVariant, pyqtSlot
style=\
"""QLabel {
qproperty-alignment: AlignCenter;
min-width: 84px;
min-height: 84px;
max-width: 84px;
max-height: 84px;
}
QLabel[state="image"]{
background-image: url(network-wired-disconnected.png);
background-repeat: no-repeat;
background-position: center;
background-color: #eeeeee;
qproperty-text: " ";
}
QLabel[state="text"]{
background-image: none;
background-repeat: no-repeat;
background-position: center;
background-color: #eeeeee;
qproperty-text: "This is<br>an<br>example";
}
"""
style2=\
"""QLabel {
qproperty-alignment: AlignCenter;
min-width: 84px;
min-height: 84px;
max-width: 84px;
max-height: 84px;
}
QLabel[state="image"]{
background-color: orange;
qproperty-text: "Image";
}
QLabel[state="text"]{
background-color: #eeeeee;
qproperty-text: "This is<br>an<br>example";
}
"""
# NO segfault!!
style3=\
"""QLabel {
qproperty-alignment: AlignCenter;
min-width: 84px;
min-height: 84px;
max-width: 84px;
max-height: 84px;
}
QLabel[state="image"]{
background-color: orange;
qproperty-text: "Image";
}
QLabel[state="text"]{
background-color: #eeeeee;
qproperty-text: "Text";
}
"""
style4=\
"""QLabel {
qproperty-alignment: AlignCenter;
border: 1px solid #cccccc;
border-bottom: 1px solid white;
background-color: #eeeeee;
padding: 2px;
font-size: 15px;
font-family: "free sans";
qproperty-alignment: AlignCenter;
min-width: 84px;
min-height: 84px;
max-width: 84px;
max-height: 84px;
}
QLabel[state="image"]{
background-color: orange;
qproperty-text: "Image";
}
QLabel[state="text"]{
background-color: #eeeeee;
qproperty-text: "<table><tr><td>This is a</td></tr><tr><td>Text</td></tr></table>";
}
"""
# NO segfault!!
style5=\
"""QLabel {
qproperty-alignment: AlignCenter;
min-width: 84px;
min-height: 84px;
max-width: 84px;
max-height: 84px;
}
QLabel[state="image"]{
background-image: url(network-wired-disconnected.png);
background-repeat: no-repeat;
background-position: center;
background-color: #eeeeee;
qproperty-text: " ";
}
QLabel[state="text"]{
background-image: none;
background-repeat: no-repeat;
background-position: center;
background-color: #eeeeee;
qproperty-text: "Text";
}
"""
# Program crashes with "segmentation fault" when
# html-tags are in the label text
# -----------------------------------
# -----------------------------------
class LabelDemoWidget(QWidget):
def __init__(self, style=style, parent=None):
QWidget.__init__(self, parent=parent)
self.style=style
self.topLabel=QLabel(self)
self.topLabel.setObjectName("topLabel")
self.label_prop="text"
self.switch={"text":"image","image":"text"}
self.setGeometry(100, 100, 100, 100)
flip=QTimer(self)
flip.setInterval(1000)
flip.timeout.connect(self.new_style)
flip.start()
# -----------------------------------
@pyqtSlot()
def new_style(self):
self.topLabel.setProperty("state",QVariant(self.switch[self.label_prop]))
self.label_prop=self.switch[self.label_prop]
self.setStyleSheet(self.style)
# -----------------------------------
if __name__=='__main__':
# usage python3 label_demo.py 0 ... 4
# 2 and 4 cause no segfault
# all others with html-tags in text will crash after some time with segfault
# debian buster (10) with python3 (3.7.3), python3-qt5 (5.11.3) out of the box
import sys
app=QApplication(sys.argv)
w = LabelDemoWidget([style, style2, style3, style4, style5][int(sys.argv[1])])
w.show()
sys.exit(app.exec_())
-- System Information:
Debian Release: 10.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-5-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages python3-pyqt5 depends on:
ii libc6 2.28-10
ii libgcc1 1:8.3.0-6
ii libpython3.7 3.7.3-2
ii libqt5core5a [qtbase-abi-5-11-3] 5.11.3+dfsg1-1
ii libqt5dbus5 5.11.3+dfsg1-1
ii libqt5designer5 5.11.3-4
ii libqt5gui5 5.11.3+dfsg1-1
ii libqt5help5 5.11.3-4
ii libqt5network5 5.11.3+dfsg1-1
ii libqt5printsupport5 5.11.3+dfsg1-1
ii libqt5test5 5.11.3+dfsg1-1
ii libqt5widgets5 5.11.3+dfsg1-1
ii libqt5xml5 5.11.3+dfsg1-1
ii libstdc++6 8.3.0-6
ii python3 3.7.3-1
ii python3-sip [sip-py3api-12.5] 4.19.14+dfsg-2
python3-pyqt5 recommends no packages.
Versions of packages python3-pyqt5 suggests:
pn python3-pyqt5-dbg <none>
-- no debconf information
More information about the Python-modules-team
mailing list