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

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.10.1
    • Fix Version/s: 5.11.3
    • Labels:
      None
    • Environment:
      OS: Windows 10, version 1803
      Compiler: msvc2017
    • Platform/s:
      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

            Assignee:
            owolff Oliver Wolff
            Reporter:
            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