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

Crash in QLowEnergyControllerPrivateWinRT::connectToDevice when removing a BLE device from Windows BT Manager

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.11.3
    • 5.10.1
    • None
    • OS: Windows 10, version 1803
      Compiler: msvc2017
    • Windows

    Description

      There is a crash on Windows related with removing (unpair) a device from the system.
      Unfortunately, currently, to work with a BLE device on Windows one need to pair a device in the system first.
      Then if a device is removed from the system while in the same time one tries to connect to it with QLowEnergyController::connectToDevice (QLowEnergyController is in ConnectingState), there is a crash (preceeded with an assert).

       

                  ComPtr<IGattReadResult> result;
                  hr = QWinRTFunctions::await(op, result.GetAddressOf());
                  if (hr == E_INVALIDARG) {
                      // E_INVALIDARG happens when user tries to connect to a device that was paired
                      // before but is not available.
                      qCDebug(QT_BT_WINRT) << "Could not obtain characteristic read result that triggers"
                                              "device connection. Is the device reachable?";
                      setError(QLowEnergyController::ConnectionError);
                      setState(QLowEnergyController::UnconnectedState);
                      return;
                  } else {
                      Q_ASSERT_SUCCEEDED(hr);
                  }
                  ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
                  hr = result->get_Value(&buffer);
      

      The crash itself is in the line: hr = result->get_Value(&buffer);. For me it seems that a QWinRTFunctions::await function returns an error but different than E_INVALIDARG. Thus the assert in Q_ASSERT_SUCCEEDED. However, because the function is stil executed there is a try to use result which is not available.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            justcode Justyna Kulińska
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes