Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15, 6.4.0 Beta1
-
None
-
-
3
-
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)
-
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.