Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.15.9
-
None
-
Boot2Qt 5.15.9/Yocto Zeus/iMX8Mini SOM from MSC
-
-
26b002e138 (qt/qtdeviceutilities/dev) 2365f80422 (qt/qtdeviceutilities/6.3) 5bcfd28a57 (qt/qtdeviceutilities/5.15) 5bcfd28a57 (qt/tqtc-qtdeviceutilities/5.15) 2365f80422 (qt/tqtc-qtdeviceutilities/6.3) 2365f80422 (qt/qtdeviceutilities/6.3.1)
Description
The commit 5dfaab214d29133bbb2f7e23726f2ef8cd8e8e08 (Do not leak QNetworkSettingsService instances for unnamed networks) introduced a crash when unplugging and reconnecting the ethernet cable in QtDeviceUtilities.
Steps to reproduce (see environment below):
- Clone qtdeviceutilities repo (https://github.com/qt/qtdeviceutilities.git) and checkout commit 1b549cce0618b1577f9dfac70c1402dbcc3562d9 (Bump version to 5.15.9)
- Plug in ethernet cable to device
- Cross compile/deploy and run settingsui
- Unplug ethernet cable, wait a second and plug-in ethernet cable
- Application crashes at:
- QNetworkSettingsManagerPrivate::onServicesChanged (line 288)
- QNetworkSettingsManagerPrivate::handleNewService(line 308)
- QNetworkSettingsServiceModel::append (line 155)
- endResetModel()
- QNetworkSettingsServiceModel::append (line 155)
- QNetworkSettingsManagerPrivate::handleNewService(line 308)
- QNetworkSettingsManagerPrivate::onServicesChanged (line 288)
Root cause:
- When ethernet connection is detected a new QNetworkSettingsService object is created in QNetworkSettingsManagerPrivate::handleNewService. (line 297)
- This new QNetworkSettingsService object is added to the m_serviceModel (line 308)
- When the ethernet cable is un-plugged the service is removed from the model in QNetworkSettingsManagerPrivate::onServicesChanged via the call m_serviceModel->removeService(path) (line 259)
- QNetworkSettingsServiceModel::removeService calls QNetworkSettingsServiceModel::remove
- In QNetworkSettingsServiceModel::remove the service is NOT removed from the model and the placeholderFlag is set (line 192)
- Back in QNetworkSettingsManagerPrivate::onServicesChanged line 265 the service is no scheduled for deletion via service->deleteLater();
- This leaves a deleted service pointer in the model and causes a crash when the network cable is inserted again.
- QNetworkSettingsServiceModel::removeService calls QNetworkSettingsServiceModel::remove
Suggested fix:
- Do not delete the service if its a placeholder service in QNetworkSettingsManagerPrivate::onServicesChanged lines 263 and 265.
I attached a suggested patch.