Bug 518245 - Crash: std::system_error EINVAL in QReadWriteLock::lockForRead() during scanPAlbums on Linux kernel 6.17 (AppImage Qt 6.10.2 vs host glibc 2.42)
Summary: Crash: std::system_error EINVAL in QReadWriteLock::lockForRead() during scanP...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Bundle-AppImage (other bugs)
Version First Reported In: 9.1.0
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-28 01:39 UTC by Ondrej Zizka
Modified: 2026-04-03 08:36 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 9.1.0
Sentry Crash Report:


Attachments
Backtrace, 9.1.0 2026-03-27, debug (168.21 KB, text/plain)
2026-03-28 01:39 UTC, Ondrej Zizka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Zizka 2026-03-28 01:39:18 UTC
Created attachment 191081 [details]
Backtrace, 9.1.0 2026-03-27, debug

digiKam crashes with "terminate called after throwing an instance of 'std::system_error' what(): Invalid argument" every time within ~30 seconds of startup, during the initial physical album scan. The crash is 100% reproducible.

It affects both the 9.0.0 release AppImage and the 9.1.0-20260327 nightly AppImage. The native Ubuntu 8.7.0 package (using system Qt 6.9.2) does NOT crash on the same system with the same collection.


ENVIRONMENT
-----------
  digiKam:                9.0.0 AppImage (Qt6) and 9.1.0-20260327T190045 nightly (Qt6)
  Qt bundled in AppImage: 6.10.2
  OS:                     Ubuntu 25.10 (Plucky Puffin)
  Kernel:                 6.17.0-19-generic (also tested 6.17.0-14 -- same crash)
  glibc (host):           2.42
  System Qt:              6.9.2 (native digikam 8.7.0 with this Qt works fine)
  Database:               MariaDB internal server
  Display:                Wayland (GNOME/Mutter); also crashes with QT_QPA_PLATFORM=xcb
  Collection:             ~2000+ physical albums


WHAT HAPPENS
------------
During startup, AlbumManager::scanPAlbums() iterates the album tree and emits signalAlbumAdded() for each album. This triggers:

  AbstractAlbumModel::slotAlbumAdded()
    -> QAbstractItemModel::endInsertRows()
      -> AbstractCheckableAlbumTreeView::rowsInserted()
        -> AbstractAlbumModel::index()
          -> Album::childAtRow()

Album::childAtRow() (album.cpp:129) constructs a QReadLocker on the album's QReadWriteLock. The QReadWriteLock::lockForRead() fast path (atomic CAS) fails due to concurrent access, and the slow path is entered. Inside Qt's QReadWriteLock slow-path implementation (frames #10-#11 in libQt6Core.so.6, symbols stripped), a POSIX threading primitive -- most likely pthread_mutex_init() or pthread_cond_init() for the internal QReadWriteLockPrivate -- returns EINVAL (22). This is wrapped by std::__throw_system_error(22), and since there is no catch in this code path, std::terminate() is called, aborting the process.


ROOT CAUSE ANALYSIS
-------------------
The AppImage bundles Qt 6.10.2 but dynamically links against the host glibc 2.42 (Ubuntu 25.10). The host glibc 2.42 ships with kernel 6.17, which introduced changes to futex and clone3 syscall validation. Qt 6.10.2 was compiled against an older glibc/kernel, and its QReadWriteLockPrivate slow-path initialization uses pthread/futex operations whose argument validation became stricter in kernel 6.17 + glibc 2.42.

Evidence that this is a bundled-Qt-vs-host-glibc mismatch:

  1. The native Ubuntu digikam 8.7.0 (using the system-provided Qt 6.9.2,
     compiled against the same glibc 2.42) works perfectly on the same
     system, same kernel, same collection.

  2. The crash occurs in Qt internals, not in digiKam code -- digiKam's
     Album::childAtRow() simply constructs a QReadLocker, which is
     standard usage.


SUGGESTED FIX
-------------
Short-term: Rebuild the AppImage's Qt against glibc >= 2.42 / kernel >= 6.17 headers, or upgrade the bundled Qt to a version that is compatible with glibc 2.42 + kernel 6.17.

Workaround for users: Use the native distribution package instead of the AppImage, or boot an older kernel (pre-6.17).


STEPS TO REPRODUCE
------------------
  1. Run Ubuntu 25.10 with kernel 6.17.x
  2. Launch digiKam 9.0.0 or 9.1.0-nightly Qt6 AppImage
  3. Open a collection with many (~2000+) physical albums backed by MariaDB
  4. Wait ~30 seconds for the collection scan to begin
  5. Crash with "std::system_error: Invalid argument"


BACKTRACE (debug nightly build, crashing thread)
-------------------------------------------------
  #0  __pthread_kill_implementation at pthread_kill.c:44
  #1  __pthread_kill_internal at pthread_kill.c:89
  #2  __GI___pthread_kill at pthread_kill.c:100
  #3  __GI_raise (sig=6) at raise.c:26
  #4  __GI_abort () at abort.c:77
  #5  ?? () from libstdc++.so.6
  #6  ?? () from libstdc++.so.6
  #7  std::terminate() from libstdc++.so.6
  #8  __cxa_throw () from libstdc++.so.6
  #9  std::__throw_system_error(int) from libstdc++.so.6          <-- EINVAL (22)
  #10 ?? () from libQt6Core.so.6                                   <-- QReadWriteLock slow path
  #11 ?? () from libQt6Core.so.6                                   <-- QReadWriteLock slow path
  #12 QReadWriteLock::lockForRead() at qreadwritelock.h:69
  #13 QReadLocker::relock() at qreadwritelock.h:116
  #14 QReadLocker::QReadLocker() at qreadwritelock.h:135
  #15 Digikam::Album::childAtRow (row=11) at album.cpp:129
  #16 Digikam::AbstractAlbumModel::index (row=11) at abstractalbummodel.cpp:264
  #17 Digikam::AbstractAlbumModel::index() at abstractalbummodel.cpp:254
  #18 Digikam::AbstractCheckableAlbumTreeView::rowsInserted() at abstractcheckablealbumtreeview.cpp:203
  #29 Digikam::AbstractAlbumModel::slotAlbumAdded() at abstractalbummodel.cpp:543
  #33 Digikam::AlbumManager::scanPAlbums() at albummanager_palbum.cpp:175
  #46 Digikam::ScanController::completeCollectionScanCore() at scancontroller_start.cpp
  #48 Digikam::NewItemsFinder::slotStart() at newitemsfinder.cpp:86
  #60 main() at main.cpp:496

Full all-threads backtrace from the debug nightly build is attached (1676 lines, personal paths redacted).
Comment 1 caulier.gilles 2026-03-29 08:33:20 UTC
One possible solution is to use the last stable Qt 6.11.0 release recently ?
Comment 2 caulier.gilles 2026-03-30 05:40:52 UTC
*** Bug 518318 has been marked as a duplicate of this bug. ***
Comment 3 caulier.gilles 2026-03-30 06:54:49 UTC
Git commit 7d335f9756beb98b3b0184a410c74311db61a38c by Gilles Caulier.
Committed on 30/03/2026 at 06:53.
Pushed by cgilles into branch 'master'.

Prepare AppImage Image bundle to build Qt 6.11.0 instead Qt 6.10.2

M  +3    -2    project/bundles/3rdparty/ext_qt6/CMakeLists.txt
A  +24   -0    project/bundles/3rdparty/ext_qt6/qt611-fix-compile.patch

https://invent.kde.org/graphics/digikam/-/commit/7d335f9756beb98b3b0184a410c74311db61a38c
Comment 4 Ondrej Zizka 2026-03-30 07:07:15 UTC
Another workaround, could be useful for someone:

Move tge album somewhere else,
DigiKam won't scan and not crash,
Move the album back and rescan,
Somehow this didn't crash.
Comment 5 Maik Qualmann 2026-03-30 07:41:13 UTC
The question is whether we even need a read/write lock to protect the QList containing the album children. We should actually always be in the GUI thread when accessing it.

However, we also seem to be having other problems with the interaction between Qt and glibc with QMutex.

Maik
Comment 6 caulier.gilles 2026-04-01 16:58:01 UTC
In one hour, the digiKam 9.1.0 pre-release AppImage bundle will be ported to last Qt 6.11.0.

File will be available here :

https://files.kde.org/digikam/

Please check if the problem is reproducible with this version.

Thanks in advance

Gilles Caulier
Comment 7 caulier.gilles 2026-04-03 08:36:18 UTC
Fixed with bug 518318