Repository navigation
Conversation
The log callback runs in the call-home client thread and copied the
matching message into a global buffer, while the test thread polled that
buffer with strlen(), which TSan reported as a data race:
WARNING: ThreadSanitizer: data race (pid=7016)
Read of size 1 at 0x0000019048f0 by thread T2:
#0 server_thread_ssh libnetconf2/tests/test_ch.c:126:15
Previous write of size 8 at 0x0000019048f0 by thread T3:
#0 strncpy
CESNET#1 test_msg_callback libnetconf2/tests/test_ch.c:54:9
CESNET#2 nc_log_vprintf libnetconf2/src/log.c:134:9
CESNET#3 nc_log_printf libnetconf2/src/log.c:152:5
CESNET#4 nc_ch_client_thread libnetconf2/src/session_server.c:4478:17
As if synchronized via sleep:
#0 usleep
CESNET#1 nc_session_free libnetconf2/src/session.c:1206:13
CESNET#2 server_thread_ssh libnetconf2/tests/test_ch.c:122:13
Location is global 'buffer' of size 512 at 0x0000019048f0 (test_ch+0x19048f0)
Thread T2 (tid=7126, running) created by main thread at:
#0 pthread_create
CESNET#1 test_nc_ch_ssh libnetconf2/tests/test_ch.c:249:11
CESNET#2 <null> <null> (libcmocka.so.0+0x618f)
CESNET#3 __libc_start_call_main /usr/src/debug/glibc-2.37-18.fc38.x86_64/csu/../sysdeps/nptl/libc_start_call_main.h:58:16
Thread T3 (tid=7127, running) created by thread T2 at:
#0 pthread_create
CESNET#1 _nc_connect_ch_client_dispatch libnetconf2/src/session_server.c:4770:14
CESNET#2 nc_connect_ch_client_dispatch libnetconf2/src/session_server.c:4813:10
CESNET#3 server_thread_ssh libnetconf2/tests/test_ch.c:113:11
SUMMARY: ThreadSanitizer: data race libnetconf2/tests/test_ch.c:126:15 in server_thread_ssh
The message text itself was never used, so replace the buffer with an
atomic flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The log callback reads the expected message from whichever thread is logging, while the test thread overwrote it with strcpy(). Point to a string literal through an atomic pointer instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michalvasko
added a commit
that referenced
this pull request
Oct 16, 2026
Member
|
Oh, I thought it is just an issue, not a pull request. In any case, I have added a lock for the messages so the error should be gone. |
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.
We hit this error in the CI: