https://bugs.kde.org/show_bug.cgi?id=518245

            Bug ID: 518245
           Summary: 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)
    Classification: Applications
           Product: digikam
      Version First 9.1.0
       Reported In:
          Platform: Ubuntu
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: Albums-MainView
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 191081
  --> https://bugs.kde.org/attachment.cgi?id=191081&action=edit
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).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to