Segmentation fault within some specific conditions
Erwan Mathieu
erwan.mathieu at ultimaker.com
Wed Mar 6 14:17:01 GMT 2024
Hello,
I'm running into a segmentation fault when using PyQt 6.6.0/6.6.1. I could
reproduce it with a very basic project, here is how to make it happen:
// File test.py
from PyQt6.QtCore import QObject
from PyQt6.QtGui import QGuiApplication
from PyQt6.QtQml import QQmlApplicationEngine, qmlRegisterType
class MyModel(QObject):
def __init__(self, parent = None):
super().__init__(parent = parent)
print("I am alive")
def __del__(self):
print("I am dead ")
app = QGuiApplication([])
qmlRegisterType(MyModel, "Test", 1, 0, "MyModel")
engine = QQmlApplicationEngine()
engine.load("./Main.qml")
app.exec()
// File Main.qml
import QtQuick
import QtQuick.Controls
import Test 1.0
Window
{
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Loader { id: loader; sourceComponent: superComponent; }
Button
{
anchors.centerIn: parent
text: "Unload"
onClicked: loader.sourceComponent = null
}
Component
{
id: superComponent
Item
{
MyModel
{
property var superProperty: "hello"
}
}
}
}
Now start the test.py file, and click on the "Unload" button. The Component
instance is destroyed, which also destroys the MyModel instance. We can see
the print instructions that says so. Just after that, I get a segmentation
fault.
For some reason, this happens only when declaring a property on the MyModel
instance. If you comment the superProperty declaration, everything is fine.
We were previously working with version 6.4.2, and this caused no issue. I
have it starting from 6.6.0 (but didn't try intermediate versions).
I also tried to make this example directly in C++, and I don't get the
error, so I think this is related to PyQt.
If it is of any help, gdb gives me the following crash point:
0x00007ffff636abb0 in QMetaObject::methodOffset() const () from
/..../lib/python3.10/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
Any idea of why this is happening, and if there is a workaround/fix ?
Kind regards,
Erwan MATHIEU
--
NOTICE: This email may contain information that is confidential or
attorney-client privileged and may constitute inside information or trade
secrets. The contents of this email are intended only for the recipient(s)
listed above. If you are not the intended recipient, you are directed not
to read, disclose, distribute or otherwise use this transmission. If you
have received this email in error, please notify the sender immediately and
delete the transmission. Delivery of this message is not intended to waive
any applicable privileges.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240306/10a589a1/attachment.htm>
More information about the PyQt
mailing list