From e4fc26e23b4313ef3ebc4232b7f1fd26df03ca71 Mon Sep 17 00:00:00 2001 From: janbar Date: Fri, 18 Oct 2024 00:15:07 +0200 Subject: [PATCH] workaround crash using android ndk>22 The crash occurs in exception handling at osmscout::FileScanner::Close() line 267: >> throw IOException(filename,"Cannot close file","File already closed"); So workaround calling FileScanner::CloseFailsafe(), which is noexcept --- android/linux-build-arm64-qt515.sh | 2 +- android/linux-build-armv7-qt515.sh | 2 +- android/linux-build-x64-qt515.sh | 2 +- android/linux-build-x86-qt515.sh | 2 +- backend/CMakeLists.txt | 2 +- backend/libosmscout.2.patch | 18 ++++++++++++++++++ backend/libosmscout.cpp17.patch | 10 +++++++--- 7 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 backend/libosmscout.2.patch diff --git a/android/linux-build-arm64-qt515.sh b/android/linux-build-arm64-qt515.sh index 58ddaac1..8d2a3bca 100755 --- a/android/linux-build-arm64-qt515.sh +++ b/android/linux-build-arm64-qt515.sh @@ -4,7 +4,7 @@ mkdir -p $BUILD_DIR export JAVA_HOME=$HOME/bin/java/jdk-17.0.12 export ANDROID_SDK_ROOT=$HOME/bin/android/sdk -export ANDROID_NDK=$HOME/bin/android/sdk/ndk/22.1.7171670 +export ANDROID_NDK=$HOME/bin/android/sdk/ndk/26.3.11579264 export QT_DIR=$HOME/bin/Qt/5.15.15/android cmake .. -B $BUILD_DIR -DCMAKE_SYSTEM_NAME=Android \ diff --git a/android/linux-build-armv7-qt515.sh b/android/linux-build-armv7-qt515.sh index 4867140a..3c3f28af 100755 --- a/android/linux-build-armv7-qt515.sh +++ b/android/linux-build-armv7-qt515.sh @@ -4,7 +4,7 @@ mkdir -p $BUILD_DIR export JAVA_HOME=$HOME/bin/java/jdk-17.0.12 export ANDROID_SDK_ROOT=$HOME/bin/android/sdk -export ANDROID_NDK=$HOME/bin/android/sdk/ndk/22.1.7171670 +export ANDROID_NDK=$HOME/bin/android/sdk/ndk/26.3.11579264 export QT_DIR=$HOME/bin/Qt/5.15.15/android cmake .. -B $BUILD_DIR -DCMAKE_SYSTEM_NAME=Android \ diff --git a/android/linux-build-x64-qt515.sh b/android/linux-build-x64-qt515.sh index 2cce352d..1a1ca645 100755 --- a/android/linux-build-x64-qt515.sh +++ b/android/linux-build-x64-qt515.sh @@ -4,7 +4,7 @@ mkdir -p $BUILD_DIR export JAVA_HOME=$HOME/bin/java/jdk-17.0.12 export ANDROID_SDK_ROOT=$HOME/bin/android/sdk -export ANDROID_NDK=$HOME/bin/android/sdk/ndk/22.1.7171670 +export ANDROID_NDK=$HOME/bin/android/sdk/ndk/26.3.11579264 export QT_DIR=$HOME/bin/Qt/5.15.15/android cmake .. -B $BUILD_DIR -DCMAKE_SYSTEM_NAME=Android \ diff --git a/android/linux-build-x86-qt515.sh b/android/linux-build-x86-qt515.sh index d81481d8..b8af0c79 100755 --- a/android/linux-build-x86-qt515.sh +++ b/android/linux-build-x86-qt515.sh @@ -4,7 +4,7 @@ mkdir -p $BUILD_DIR export JAVA_HOME=$HOME/bin/java/jdk-17.0.12 export ANDROID_SDK_ROOT=$HOME/bin/android/sdk -export ANDROID_NDK=$HOME/bin/android/sdk/ndk/22.1.7171670 +export ANDROID_NDK=$HOME/bin/android/sdk/ndk/26.3.11579264 export QT_DIR=$HOME/bin/Qt/5.15.15/android cmake .. -B $BUILD_DIR -DCMAKE_SYSTEM_NAME=Android \ diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index b7cd4f80..ef6b7a41 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -188,7 +188,7 @@ set(libosmscout_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/libosmscout") # First apply our patches in the source of lib list(APPEND libosmscout_patches - libosmscout.cpp17.patch + libosmscout.2.patch ) foreach(patch IN LISTS libosmscout_patches) execute_process( diff --git a/backend/libosmscout.2.patch b/backend/libosmscout.2.patch new file mode 100644 index 00000000..5344c7bd --- /dev/null +++ b/backend/libosmscout.2.patch @@ -0,0 +1,18 @@ +diff --git a/libosmscout/src/osmscout/db/LocationIndex.cpp b/libosmscout/src/osmscout/db/LocationIndex.cpp +index 991eead42..d34241f43 100644 +--- a/libosmscout/src/osmscout/db/LocationIndex.cpp ++++ b/libosmscout/src/osmscout/db/LocationIndex.cpp +@@ -133,12 +133,7 @@ namespace osmscout { + + void LocationIndex::FileScannerPool::Destroy(FileScanner* o) noexcept + { +- try{ +- o->Close(); +- } catch (const IOException& e) { +- log.Error() << e.GetDescription(); +- o->CloseFailsafe(); +- } ++ o->CloseFailsafe(); + delete o; + } + diff --git a/backend/libosmscout.cpp17.patch b/backend/libosmscout.cpp17.patch index eb63536d..48ac9c32 100644 --- a/backend/libosmscout.cpp17.patch +++ b/backend/libosmscout.cpp17.patch @@ -1,13 +1,17 @@ diff --git a/libosmscout/include/osmscout/feature/ChargingStationFeature.h b/libosmscout/include/osmscout/feature/ChargingStationFeature.h -index be79544e6..7e376ed2c 100644 +index be79544e6..48c2cb10d 100644 --- a/libosmscout/include/osmscout/feature/ChargingStationFeature.h +++ b/libosmscout/include/osmscout/feature/ChargingStationFeature.h -@@ -51,7 +51,7 @@ namespace osmscout { +@@ -51,7 +51,11 @@ namespace osmscout { uint8_t capacity; std::string output; - std::strong_ordering operator<=>(const Socket& other) const = default; -+ bool operator==(const Socket& other) const = default; ++ bool operator==(const Socket& other) const { ++ return this->type == other.type && ++ this->capacity == other.capacity && ++ this->output == other.output; ++ } }; private: