Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.9.2, 5.9.3, 5.10.0, 5.11.0
-
None
-
Ubuntu 17.04
gcc 6.3.0
Qt 5.9.2, Qt5.10.0, Qt5.11.0
Ubuntu 14.04
gcc 4.8.4
Qt 5.9.3, Qt5.10.0
-
864e4a8ab514ddcd7f79106a6b447f7a1d5b5d4e (qt/qtserialbus/5.11)
Description
A timer is connected to a slot that initializes a QModbusRtuSerialMaster to send a request and wait for the reply.
First time the slot is called I receive the good response, second time I get a memory corruption.
I create a minimal project example that reproduce the error, code is attached but here is my slot:
void MainWindow::onTimerTimeout() { qDebug("slot called"); QModbusRtuSerialMaster _modbusSerialMaster; _modbusSerialMaster.setConnectionParameter(QModbusDevice::SerialDataBitsParameter, QSerialPort::Data8); _modbusSerialMaster.setConnectionParameter(QModbusDevice::SerialParityParameter, QSerialPort::NoParity); _modbusSerialMaster.setConnectionParameter(QModbusDevice::SerialStopBitsParameter, QSerialPort::OneStop); _modbusSerialMaster.setConnectionParameter(QModbusDevice::SerialBaudRateParameter, QSerialPort::Baud115200); _modbusSerialMaster.setConnectionParameter(QModbusDevice::SerialPortNameParameter, "/dev/ttyUSB0"); _modbusSerialMaster.setNumberOfRetries(2); if(_modbusSerialMaster.connectDevice()) { qDebug("connected"); QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 511, 3); if(auto *reply = _modbusSerialMaster.sendReadRequest(request, 9)) { qDebug("reply"); while(!reply->isFinished()) { QCoreApplication::processEvents(QEventLoop::AllEvents); } qDebug() << reply->result().values(); reply->deleteLater(); } _modbusSerialMaster.disconnectDevice(); } timer.start(); }
and the output:
slot called connected reply QVector(17920, 30676, 0) slot called *** Error in `/home/malacasse/dev/build-testModbus-Desktop_Qt_5_9_2_GCC_64bit-Debug/testModbus': malloc(): memory corruption (fast): 0x0000555555b1a7ff *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x7908b)[0x7ffff633b08b] /lib/x86_64-linux-gnu/libc.so.6(+0x85008)[0x7ffff6347008] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7ffff6348984] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(_Znwm+0x18)[0x7ffff692faf8] /opt/Qt/5.9.2/gcc_64/lib/libQt5SerialBus.so.5(_ZN22QModbusRtuSerialMasterC1EP7QObject+0x34d)[0x7ffff7385fbd] /home/malacasse/dev/build-testModbus-Desktop_Qt_5_9_2_GCC_64bit-Debug/testModbus(+0x3227)[0x555555557227] /home/malacasse/dev/build-testModbus-Desktop_Qt_5_9_2_GCC_64bit-Debug/testModbus(+0x44b3)[0x5555555584b3] /opt/Qt/5.9.2/gcc_64/lib/libQt5Core.so.5(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x659)[0x7ffff6ecb869] /opt/Qt/5.9.2/gcc_64/lib/libQt5Core.so.5(_ZN6QTimer7timeoutENS_14QPrivateSignalE+0x27)[0x7ffff6ed8057] .......