fix: use atomic loads for clip state and buffer_size in engine_process_commands

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 11:23:00 +00:00
parent b6cea54a89
commit 6ca2a4c01a
67 changed files with 198 additions and 4 deletions

82
tsan_report.log Normal file
View File

@@ -0,0 +1,82 @@
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (pid=928821)
#0 pthread_mutex_unlock <null> (libtsan.so.2+0x5c2ec) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libpipewire-0.3.so.0+0xd250) (BuildId: 6c351c9a14f26a16201ad1530bbec8bc2bdf8106)
Location is heap block of size 1512 at 0x726800001200 allocated by main thread:
#0 calloc <null> (libtsan.so.2+0x9126c) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libpipewire-0.3.so.0+0x6bbef) (BuildId: 6c351c9a14f26a16201ad1530bbec8bc2bdf8106)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Mutex M0 (0x726800001710) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x5e23a) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libspa-support.so+0x8bd0) (BuildId: 24a3df4fe9996f17f516f9dca3d5b18bfce2133f)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (/usr/lib/libpipewire-0.3.so.0+0xd250) (BuildId: 6c351c9a14f26a16201ad1530bbec8bc2bdf8106)
==================
==================
WARNING: ThreadSanitizer: data race (pid=928821)
Read of size 8 at 0x5598ba988108 by thread T4 (mutexes: write M0, write M1):
#0 engine_process_commands /home/jt/code/wheelie/engine.c:453 (jack-looper+0x64b4) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#1 process_callback /home/jt/code/wheelie/engine.c:24 (jack-looper+0x3c4f) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#2 <null> <null> (libjack.so.0+0x1fc6a) (BuildId: a070bcfa4955ac5fd8a632489cd56f534a7dfc66)
Previous write of size 4 at 0x5598ba988108 by main thread:
#0 engine_submit_command /home/jt/code/wheelie/engine.c:429 (jack-looper+0x62ad) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#1 engine_transport_toggle_play /home/jt/code/wheelie/engine.c:1176 (jack-looper+0xb9dd) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#2 tui_run /home/jt/code/wheelie/tui.c:694 (jack-looper+0xe81e) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#3 main /home/jt/code/wheelie/main.c:95 (jack-looper+0x3b86) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Location is global 'engine' of size 39432 at 0x5598ba987440 (jack-looper+0x21108)
Mutex M0 (0x726800001710) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x5e23a) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libspa-support.so+0x8bd0) (BuildId: 24a3df4fe9996f17f516f9dca3d5b18bfce2133f)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Mutex M1 (0x728400000550) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x5e23a) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 jack_client_open <null> (libjack.so.0+0x1d691) (BuildId: a070bcfa4955ac5fd8a632489cd56f534a7dfc66)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Thread T4 'data-loop.0' (tid=928826, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.2+0x5fb47) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libpipewire-0.3.so.0+0x90c47) (BuildId: 6c351c9a14f26a16201ad1530bbec8bc2bdf8106)
#2 main /home/jt/code/wheelie/main.c:79 (jack-looper+0x3a85) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
SUMMARY: ThreadSanitizer: data race /home/jt/code/wheelie/engine.c:453 in engine_process_commands
==================
==================
WARNING: ThreadSanitizer: data race (pid=928821)
Read of size 4 at 0x5598ba988114 by thread T4 (mutexes: write M0, write M1):
#0 engine_process_commands /home/jt/code/wheelie/engine.c:453 (jack-looper+0x64b4) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#1 process_callback /home/jt/code/wheelie/engine.c:24 (jack-looper+0x3c4f) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#2 <null> <null> (libjack.so.0+0x1fc6a) (BuildId: a070bcfa4955ac5fd8a632489cd56f534a7dfc66)
Previous write of size 4 at 0x5598ba988114 by main thread:
#0 engine_submit_command /home/jt/code/wheelie/engine.c:429 (jack-looper+0x62ad) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#1 engine_reset_clip /home/jt/code/wheelie/engine.c:1137 (jack-looper+0xb748) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#2 tui_run /home/jt/code/wheelie/tui.c:644 (jack-looper+0xe62a) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
#3 main /home/jt/code/wheelie/main.c:95 (jack-looper+0x3b86) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Location is global 'engine' of size 39432 at 0x5598ba987440 (jack-looper+0x21114)
Mutex M0 (0x726800001710) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x5e23a) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libspa-support.so+0x8bd0) (BuildId: 24a3df4fe9996f17f516f9dca3d5b18bfce2133f)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Mutex M1 (0x728400000550) created at:
#0 pthread_mutex_init <null> (libtsan.so.2+0x5e23a) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 jack_client_open <null> (libjack.so.0+0x1d691) (BuildId: a070bcfa4955ac5fd8a632489cd56f534a7dfc66)
#2 main /home/jt/code/wheelie/main.c:67 (jack-looper+0x39f9) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
Thread T4 'data-loop.0' (tid=928826, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.2+0x5fb47) (BuildId: f29521f558650bcc384c0178d8c6d0fd49466e29)
#1 <null> <null> (libpipewire-0.3.so.0+0x90c47) (BuildId: 6c351c9a14f26a16201ad1530bbec8bc2bdf8106)
#2 main /home/jt/code/wheelie/main.c:79 (jack-looper+0x3a85) (BuildId: ed86a50eccffb9d745f9683ba76a2748ef793573)
SUMMARY: ThreadSanitizer: data race /home/jt/code/wheelie/engine.c:453 in engine_process_commands
==================
ThreadSanitizer: reported 3 warnings