Repository navigation
fixes for two more TSAN races - #651
Merged
Merged
Conversation
The client thread logs while setting up its call-home bind, so the log
callback can read the expected message while the server thread is still
writing it:
WARNING: ThreadSanitizer: data race (pid=3869790)
Read of size 8 at 0x555556aa75b0 by thread T7 (mutexes: write M0):
#0 strstr <null>
CESNET#1 test_msg_callback tests/test_ch.c:55:9
CESNET#2 nc_log_vprintf src/log.c:134:9
CESNET#3 nc_log_printf src/log.c:152:5
CESNET#4 nc_sock_bind_inet src/session_server.c
CESNET#5 nc_sock_listen_inet src/session_server.c:563:9
CESNET#6 nc_client_ch_add_bind_listen src/session_client.c:1765:12
CESNET#7 nc_client_ssh_ch_add_bind_listen src/session_client_ssh.c:1268:12
CESNET#8 client_thread_delete_while_session tests/test_ch.c:504:11
Previous write of size 8 at 0x555556aa75b0 by thread T8:
#0 __tsan_memcpy <null>
CESNET#1 server_thread_delete_while_session tests/test_ch.c:447:5
Location is global 'expected' of size 512 at 0x555556aa75b0
Reset both the buffer and the expected message under the lock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The print callback may be changed while other threads are logging, as
test_ch does when the server thread installs its callback while the
client thread is already setting up its call-home bind:
WARNING: ThreadSanitizer: data race (pid=3869790)
Read of size 8 at 0x555556aa6f78 by thread T7:
#0 nc_log_vprintf src/log.c:133:9
CESNET#1 nc_log_printf src/log.c:152:5
CESNET#2 nc_sock_bind_inet src/session_server.c
CESNET#3 nc_sock_listen_inet src/session_server.c:563:9
CESNET#4 nc_client_ch_add_bind_listen src/session_client.c:1765:12
CESNET#5 nc_client_ssh_ch_add_bind_listen src/session_client_ssh.c:1268:12
CESNET#6 client_thread_delete_while_session tests/test_ch.c:504:11
Previous write of size 8 at 0x555556aa6f78 by thread T8:
#0 nc_set_print_clb_session src/log.c:159:15
CESNET#1 server_thread_delete_while_session tests/test_ch.c:445:5
Location is global 'print_clb' of size 8 at 0x555556aa6f78
Store it as an atomic pointer, just like the verbosity level.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michalvasko
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was checking whether commit ac86ff1 fixed all problems that I hit in #648, and there's a couple more.