Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-103327

QtDeviceUtilites crashes when un-plugging and re-connecting ethernet cable



    • Linux/Yocto
    • 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)


      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):

      1. Clone qtdeviceutilities repo (https://github.com/qt/qtdeviceutilities.git) and checkout commit 1b549cce0618b1577f9dfac70c1402dbcc3562d9 (Bump version to 5.15.9)
      2. Plug in ethernet cable to device
      3. Cross compile/deploy and run settingsui
      4. Unplug ethernet cable, wait a second and plug-in ethernet cable 
      5. Application crashes at:
        1. QNetworkSettingsManagerPrivate::onServicesChanged (line 288)
          1. QNetworkSettingsManagerPrivate::handleNewService(line 308)
            1. QNetworkSettingsServiceModel::append (line 155)
              1. endResetModel()

      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. 

      Suggested fix:

      • Do not delete the service if its a placeholder service in QNetworkSettingsManagerPrivate::onServicesChanged lines 263 and 265.

      I attached a suggested patch. 


        For Gerrit Dashboard: QTBUG-103327
        # Subject Branch Project Status CR V



            papetaja Pasi Petäjäjärvi
            christof_schultz Christof Schultz
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes