Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Crash on shutdown using QGeoAreaMonitorSource on Android

Crash on shutdown using QGeoAreaMonitorSource on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 118 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Code Monkey George
    wrote on last edited by
    #1

    Hi,

    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 API 31, 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) (in Src/qtlocation/src/plugins/position/android/src/jnipositioning.cpp) is accessing a nullptr, presumably due to a shutdown sequencing issue that has made idToPosSource() invalid.

    Is there a way to shutdown cleanly on Android when using QGeoAreaMonitorSource, or is this a bug in Qt Positioning?

    Thanks!

    CMG

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved