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

QGeoAreaMonitorSource seg fault on exit on Android

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15, 6.4.0 Beta1
    • Fix Version/s: 6.2.5, 6.3.1, 6.4.0 Beta1
    • Component/s: Positioning
    • Labels:
      None
    • Platform/s:
      Android
    • Story Points:
      3
    • Commits:
      5e91bb7a8a (qt/qtpositioning/dev) e982ecf04f (qt/qtpositioning/6.3) e982ecf04f (qt/tqtc-qtpositioning/6.3) 5e91bb7a8a (qt/tqtc-qtpositioning/dev) 0df7ff8e9a (qt/tqtc-qtlocation/5.15) 1356b01b29 (qt/tqtc-qtpositioning/6.2) 5e91bb7a8a (qt/qtpositioning/6.4)
    • Sprint:
      Team A Foundation Sprint 58

      Description

      I'm encountering a crash related to QGeoAreaMonitorSource during app shutdown on Android with Qt 5.15.

      Minimum code to reproduce below. This code works fine on desktop (Linux), but crashes on Android (testing on Android emulator with API31, but I've seen it on other Android devices).

      The two cases where it doesn't crash are (1) if you don't call createDefaultSource() (i.e. nothing to cleanup), or (2) if the app gets shutdown by the OS (e.g. by swiping up from the app switcher). A normal quit() call from within the app results in this error. It doesn't seem to matter when or even if I delete my pointer to QGeoAreaMonitorSource, the crash persists.

      #include <QGuiApplication>
      #include <QGeoAreaMonitorSource>
      #include <QTimer>
      ​
      int main(int argc, char *argv[])
      {
         QGuiApplication app(argc, argv);
      ​
         QGeoAreaMonitorSource* pMonitorSrc
             = QGeoAreaMonitorSource::createDefaultSource( nullptr );
         QTimer::singleShot( 1000, [&]() {
             delete pMonitorSrc;
             app.quit();
         } );
      ​
         int rc = app.exec();
         return rc;
      }
      

      The crash is a seg-fault with call stack:                                                                      

       
      1  AndroidPositioning::unregisterPositionInfoSource(int)                             0x7e59a7a4f4b7     
      2  QGeoPositionInfoSourceAndroid::~QGeoPositionInfoSourceAndroid()                   0x7e59a7a4e685     
      3  QGeoPositionInfoSourceAndroid::~QGeoPositionInfoSourceAndroid()                   0x7e59a7a4e729     
      4  QObjectPrivate::deleteChildren()                                                  0x7e59b26a07a5     
      5  QObject::~QObject()                                                               0x7e59b26a0672     
      6  (anonymous namespace)::Q_QGS_pollingPrivate::innerFunction()::Holder::~Holder()   0x7e59a471ae16     
      7  __cxa_finalize                                                                    0x7e5ccf85d5d2     
      8  exit                                                                              0x7e5ccf84f2cf     
      9  startQtApplication(_JNIEnv *, _jclass *)                                          0x7e59a50f6423     
      10 ??                                                                                0x7e5a25b9ffac     
      11 ??                                                                                0x98ad35e000000001 
      12 ??                                                                                0x7e5b             
      13 ??                                                                                0x7e5a0abc1cc0     
      14 ??                                                                                0x2798ad35e0       
      15 ??                          
      

      I believe the segfault happens because idToPosSource()->remove(key) is accessing a nullptr, presumably due to a shutdown sequencing issue.

        Attachments

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

          Activity

            People

            Assignee:
            ivan.solovev Ivan Solovev
            Reporter:
            cmg George Coder
            PM Owner:
            Vladimir Minenko Vladimir Minenko
            RnD Owner:
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes