vmware / vmware/splinterdb

TSAN warnings: destroy of a locked mutex

Open
#198 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
732
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Building with ThreadSanitizer and running tests shows this error:

SUMMARY: ThreadSanitizer: destroy of a locked mutex src/platform_linux/platform.c:153 in platform_mutex_destroy
==================
==================
WARNING: ThreadSanitizer: destroy of a locked mutex (pid=205274)
    #0 pthread_mutex_destroy ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1237 (libtsan.so.0+0x3725c)
    #1 platform_mutex_destroy src/platform_linux/platform.c:153 (libsplinterdb.so+0x4312e)
    #2 task_group_deinit src/task.c:346 (libsplinterdb.so+0x465e2)
    #3 task_system_destroy src/task.c:646 (libsplinterdb.so+0x4790f)
    #4 kvstore_close src/kvstore.c:321 (libsplinterdb.so+0x174e1)
    #5 kvstore_basic_close src/kvstore_basic.c:338 (libsplinterdb.so+0x9e461)
    #6 test_kvstore_iterator_with_startkey tests/functional/kvstore_basic_test.c:705 (driver_test+0x1a5bd)
    #7 kvstore_basic_test tests/functional/kvstore_basic_test.c:1226 (driver_test+0x1d7bb)
    #8 test_dispatcher tests/functional/test_dispatcher.c:49 (driver_test+0x45d71)
    #9 main tests/functional/driver_test.c:13 (driver_test+0x45765)

  and:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4165 (libtsan.so.0+0x526fc)
    #1 platform_mutex_lock src/platform_linux/platform_inline.h:158 (libsplinterdb.so+0x451bc)
    #2 task_group_stop_and_wait_for_threads src/task.c:317 (libsplinterdb.so+0x463f7)
    #3 task_group_deinit src/task.c:342 (libsplinterdb.so+0x465a1)
    #4 task_system_destroy src/task.c:646 (libsplinterdb.so+0x4790f)
    #5 kvstore_close src/kvstore.c:321 (libsplinterdb.so+0x174e1)
    #6 kvstore_basic_close src/kvstore_basic.c:338 (libsplinterdb.so+0x9e461)
    #7 test_kvstore_iterator_with_startkey tests/functional/kvstore_basic_test.c:705 (driver_test+0x1a5bd)
    #8 kvstore_basic_test tests/functional/kvstore_basic_test.c:1226 (driver_test+0x1d7bb)
    #9 test_dispatcher tests/functional/test_dispatcher.c:49 (driver_test+0x45d71)
    #10 main tests/functional/driver_test.c:13 (driver_test+0x45765)

  Location is heap block of size 1250240 at 0x7f9951cce000 allocated by main thread:
    #0 aligned_alloc ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:799 (libtsan.so.0+0x300a8)
    #1 platform_aligned_malloc src/platform_linux/platform_inline.h:390 (libsplinterdb.so+0x45372)
    #2 platform_aligned_zalloc src/platform_linux/platform.h:599 (libsplinterdb.so+0x4546e)
    #3 task_system_create src/task.c:595 (libsplinterdb.so+0x47629)
    #4 kvstore_create_or_open src/kvstore.c:191 (libsplinterdb.so+0x16d55)
    #5 kvstore_create src/kvstore.c:284 (libsplinterdb.so+0x173af)
    #6 kvstore_basic_create_or_open src/kvstore_basic.c:309 (libsplinterdb.so+0x9e2d7)
    #7 kvstore_basic_create src/kvstore_basic.c:324 (libsplinterdb.so+0x9e3cb)
    #8 setup_kvstore_basic tests/functional/kvstore_basic_test.c:63 (driver_test+0x16226)
    #9 test_kvstore_iterator_with_startkey tests/functional/kvstore_basic_test.c:677 (driver_test+0x1a1e5)
    #10 kvstore_basic_test tests/functional/kvstore_basic_test.c:1226 (driver_test+0x1d7bb)
    #11 test_dispatcher tests/functional/test_dispatcher.c:49 (driver_test+0x45d71)
    #12 main tests/functional/driver_test.c:13 (driver_test+0x45765)

  Mutex M1346 (0x7f9951ccf528) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 platform_mutex_init src/platform_linux/platform.c:143 (libsplinterdb.so+0x430ef)
    #2 task_group_init src/task.c:380 (libsplinterdb.so+0x467c9)
    #3 task_system_create src/task.c:613 (libsplinterdb.so+0x47768)
    #4 kvstore_create_or_open src/kvstore.c:191 (libsplinterdb.so+0x16d55)
    #5 kvstore_create src/kvstore.c:284 (libsplinterdb.so+0x173af)
    #6 kvstore_basic_create_or_open src/kvstore_basic.c:309 (libsplinterdb.so+0x9e2d7)
    #7 kvstore_basic_create src/kvstore_basic.c:324 (libsplinterdb.so+0x9e3cb)
    #8 setup_kvstore_basic tests/functional/kvstore_basic_test.c:63 (driver_test+0x16226)
    #9 test_kvstore_iterator_with_startkey tests/functional/kvstore_basic_test.c:677 (driver_test+0x1a1e5)
    #10 kvstore_basic_test tests/functional/kvstore_basic_test.c:1226 (driver_test+0x1d7bb)
    #11 test_dispatcher tests/functional/test_dispatcher.c:49 (driver_test+0x45d71)
    #12 main tests/functional/driver_test.c:13 (driver_test+0x45765)

Apparently that's undefined behavior

TSAN also complains about lots of data races, which are too numerous to list here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TSAN trace in src/platform_linux/platform.c:153 and the shutdown path through src/task.c:317, 342, and 346. Reproduce the warning using the functional test path in tests/functional/kvstore_basic_test.c, especially test_kvstore_iterator_with_startkey. Done means the locked-mutex warning and the relevant reported task-system races no longer appear under ThreadSanitizer.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.