Created attachment 159836 [details] Sample CMakeLists project to reproduce the crash SUMMARY Marble container iterators (e.g. GeoDataLineString::constBegin) usage causes segmentation fault. By default, marble is compiled with QT_STRICT_ITERATORS definition for non-Windows platforms, which probably results in ODR violation when other projects without this definition link to the library. I believe that's the main reason for this bug as well: https://bugs.kde.org/show_bug.cgi?id=458555 Compiling the project with explicitly enabled definition fixes described behaviour. If that define is cricital enough to cause crashes, I expect it to be mentioned in docs. STEPS TO REPRODUCE 1. Create an empty C++ project which links to marble & qt 2. Compile & execute the following code: #include <marble/GeoDataLineString.h> #include <marble/GeoDataCoordinates.h> #include <cassert> #include <iostream> int main() { using Marble::GeoDataLineString; using Marble::GeoDataCoordinates; GeoDataLineString line {}; for ( size_t i = 0, j = 0; i < 10; ++i, ++j ) line << GeoDataCoordinates{j + 1.0, j + 2.0, j + 3.0}; for ( size_t i = 0; i < line.size(); ++i ) { const auto& point = static_cast <const GeoDataLineString&> (line).at(i); std::cout << "point " << i << ": lon " << point.longitude() << " lat " << point.latitude() << " alt " << point.altitude(); std::cout << "\n"; } assert(line.size() > 0); assert(line.isEmpty() == false); assert(line.constBegin() != line.constEnd()); assert(line.begin() != line.end()); return 0; } OBSERVED RESULT Segmentation fault at third assert during the call to line.constBegin(): 1 Marble::GeoDataLineString::constBegin() const 0x7f94865c47bb 2 main main.cpp 31 0x563cf7795b4b Adding QT_STRICT_ITERATORS definition eliminates the crash. EXPECTED RESULT Successful execution. SOFTWARE/OS VERSIONS Linux: archlinux 6.3.9-arch1-1 Qt Version: 5.15.10+kde+r129-1 ADDITIONAL INFORMATION The issue is probably non-existent on Windows, since the library is compiled with strict iterators disabled for this platform by default
The only solution I can propose is to make QT_STRICT_ITERATORS definition in the library public: if (NOT WIN32) target_compile_definitions(marblewidget PUBLIC QT_STRICT_ITERATORS) endif()