Details
-
Bug
-
Resolution: Invalid
-
P1: Critical
-
None
-
5.12.0
-
Ubuntu 18.10 Desktop 64 bit, gcc 7.3, Qt 5.12
Description
There is a Qml Button with 2 states( connect/disconnect ) inside my App. Here is the respective code :
Button { id : connectDisconnectButton anchors.centerIn: parent property bool isConnected : false text : isConnected ? qsTr("Disconnect") : qsTr("Connect") antialiasing: true property var currentConnectionParams : ({}) onClicked: { if ( isConnected ) { proxy.disconnectFromEmulatorService(); } else { connectDisconnectButton.currentConnectionParams["port"] = serviceConnectionPort.getValue(); connectDisconnectButton.currentConnectionParams["ip_addr"] = String(serviceConnectionIpPart_0.getValue()) + String(".") + String(serviceConnectionIpPart_1.getValue()) + String(".") + String(serviceConnectionIpPart_2.getValue()) + String(".") + String(serviceConnectionIpPart_3.getValue()); proxy.connectToEmulatorService( connectDisconnectButton.currentConnectionParams ); } isConnected = !isConnected; } }
What I see is that from time to time I get SIGSEGV while calling connectToEmulatorService method of my C++ proxy. Here is the respective c++ code :
Q_INVOKABLE void connectToEmulatorService( QVariant ) { m_serviceConnectionParams = in; emit connectionInitiatedSignal(); m_functorExecutor->executeFunctor( boost::bind(&EmulatorControlProxy::connectToEmulatorServiceImpl, this ) ); } void connectToEmulatorServiceImpl() { QMap<QString, QVariant> connectionParams_ = m_serviceConnectionParams.toMap(); try { emit connectionOkSignal(); }catch(...) { Error("connectToEmulatorServiceImpl failure : ip = %s, port = %s", connectionParams_["ip_addr"].toString().toStdString().c_str(), connectionParams_["port"].toString().toStdString().c_str() ); emit connectionFailedSignal(); } }
GDB backtrace gives the following output :
(gdb) backtrace #0 0x00007ffff6e0777b in QV4::QObjectWrapper::virtualGet(QV4::Managed const*, QV4::PropertyKey, QV4::Value const*, bool*) () at /home/developer/Qt5.12.0/5.12.0/gcc_64/lib/libQt5Qml.so.5 #1 0x00007ffff6e8802b in QV4::Runtime::method_loadProperty(QV4::ExecutionEngine*, QV4::Value const&, int) () at /home/developer/Qt5.12.0/5.12.0/gcc_64/lib/libQt5Qml.so.5 #2 0x00007fffe0003d9a in () #3 0x0000000000000000 in ()
PS. The problem is somehow related to
QMap<QString, QVariant> connectionParams_ = m_serviceConnectionParams.toMap();
It seems that temporary QML object map is being deleted before functorExecutor thread tries to access it. But why does it happen, if I copy incoming QVariant to a class member variable? As a workaround I declared a bunch of Q_PROPERTY for my proxy to store QML data there before invoke C++.