Skip to content

SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) sqlcipher/sqlite3.c:40233 in unixEnterMutex #582

@zoff99

Description

@zoff99

after upgrading to sqlcipher 4.12.0 i get this error when running a test program with TSAN test.
it used to work fine for ages with lots of previous versions of sqlcipher.
the last known working sqlcipher was 4.11.0

this is the test program: https://github.com/zoff99/iocipher_pack/blob/master/002_src_libsqlfs/tests/common.c

this is the CI run thats showing the issue: https://github.com/zoff99/iocipher_pack/actions/runs/20169599733/job/57901559928

2025-12-12T14:38:34.6356156Z WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=110497)
2025-12-12T14:38:34.6356333Z   Cycle in lock order graph: M63 (0x7b0c00005c48) => M62 (0x559037654d28) => M63
2025-12-12T14:38:34.6356339Z 
2025-12-12T14:38:34.6356485Z   Mutex M62 acquired here while holding mutex M63 in main thread:
2025-12-12T14:38:34.6356941Z     #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
2025-12-12T14:38:34.6357096Z     #1 unixEnterMutex sqlcipher/sqlite3.c:40233 (c_api+0xbe49e)
2025-12-12T14:38:34.6357255Z     #2 unixIsSharingShmNode sqlcipher/sqlite3.c:44012 (c_api+0xbe49e)
2025-12-12T14:38:34.6357368Z     #3 unixLock sqlcipher/sqlite3.c:41363 (c_api+0xbe49e)
2025-12-12T14:38:34.6357476Z     #4 unixLock sqlcipher/sqlite3.c:41198 (c_api+0xbe49e)
2025-12-12T14:38:34.6357565Z     #5 <null> <null> (libc.so.6+0x29d8f)
2025-12-12T14:38:34.6357569Z 
2025-12-12T14:38:34.6357784Z     Hint: use TSAN_OPTIONS=second_deadlock_stack=1 to get more informative warning message
2025-12-12T14:38:34.6357907Z 
2025-12-12T14:38:34.6358055Z   Mutex M63 acquired here while holding mutex M62 in main thread:
2025-12-12T14:38:34.6358448Z     #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
2025-12-12T14:38:34.6358565Z     #1 unixClose sqlcipher/sqlite3.c:41682 (c_api+0xeef46)
2025-12-12T14:38:34.6358646Z     #2 <null> <null> (libc.so.6+0x29d8f)
2025-12-12T14:38:34.6358657Z 
2025-12-12T14:38:34.6359023Z SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) sqlcipher/sqlite3.c:40233 in unixEnterMutex
2025-12-12T14:38:34.6359088Z ==================
2025-12-12T14:38:34.6359177Z ThreadSanitizer: reported 1 warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions