-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSAN: don't race through pthread_cond_destroy
#477
Merged
Merged
Conversation
This file contains 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
In the `test_ch` test, the `test_nc_ch_tls` case would result in the following report: WARNING: ThreadSanitizer: data race (pid=7309) Write of size 8 at 0x7b24000148e0 by thread T6: #0 pthread_cond_destroy <null> (test_ch+0x459fd1) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) CESNET#1 nc_ch_client_thread /home/ci/src/cesnet-gerrit-public/CzechLight/dependencies/libnetconf2/src/session_server.c:2909:5 (test_ch+0x4f9f85) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) Previous read of size 8 at 0x7b24000148e0 by thread T5 (mutexes: write M0, write M1): #0 pthread_cond_signal <null> (test_ch+0x459c6c) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) CESNET#1 nc_server_config_destroy_ch_client /home/ci/src/cesnet-gerrit-public/CzechLight/dependencies/libnetconf2/src/server_config.c:920:9 (test_ch+0x4fb12a) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) CESNET#2 nc_server_config_ch /home/ci/src/cesnet-gerrit-public/CzechLight/dependencies/libnetconf2/src/server_config.c:1039:9 (test_ch+0x4fdd27) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) CESNET#3 nc_server_config_setup_data /home/ci/src/cesnet-gerrit-public/CzechLight/dependencies/libnetconf2/src/server_config.c:4211:5 (test_ch+0x4fdd27) CESNET#4 server_thread_tls /home/ci/src/cesnet-gerrit-public/CzechLight/dependencies/libnetconf2/tests/test_ch.c:307:11 (test_ch+0x522849) (BuildId: 0dd508005b002d2a874ae63746b8b5ea13e50df5) The pthread_cond_destroy(3p) documentation says that: > It shall be safe to destroy an initialized condition variable upon > which no threads are currently blocked. Attempting to destroy a > condition variable upon which other threads are > currently blocked results in undefined behavior. Let's make sure that this is the case by locking the associated mutex.
jktjkt
added a commit
to CESNET/CzechLight-dependencies
that referenced
this pull request
Apr 10, 2024
Change-Id: I64fc283d17075bd5236243cc7072b11b53570e48 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/7049 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/sysrepo-cpp/+/7033 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libnetconf2-cpp/+/7041 Depends-on: CESNET/libnetconf2#477 Depends-on: CESNET/libnetconf2#478
jktjkt
added a commit
to CESNET/CzechLight-dependencies
that referenced
this pull request
Apr 10, 2024
Change-Id: I64fc283d17075bd5236243cc7072b11b53570e48 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/7049 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/sysrepo-cpp/+/7033 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libnetconf2-cpp/+/7041 Depends-on: CESNET/libnetconf2#477 Depends-on: CESNET/libnetconf2#478
jktjkt
added a commit
to CESNET/libnetconf2-cpp
that referenced
this pull request
Apr 10, 2024
This is really just a change of logging, nothing else. Unfortunately, the new logging still affects a global state, it was really just a change of the function signature, and the logger callback might well be invoked with a NULL session. This means that mapping from the nc_session* to a libnetconf::client::Session is not possible, so I though that simply providing an opaque pointer is not a bad solution. Change-Id: Iaa10855f4173fdd5e3046efa1827e4931cd05acb Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/7049 Depends-on: CESNET/libnetconf2#477 Depends-on: CESNET/libnetconf2#478
jktjkt
added a commit
to CESNET/CzechLight-dependencies
that referenced
this pull request
Apr 10, 2024
Change-Id: I64fc283d17075bd5236243cc7072b11b53570e48 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/7049 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/sysrepo-cpp/+/7033 Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libnetconf2-cpp/+/7041 Depends-on: CESNET/libnetconf2#477 Depends-on: CESNET/libnetconf2#478
I do not think this change actually prevents any run-time errors and just makes TSAN happy, which is something I consider a waste of time. But since I have no problem with the change, it can be merged, thanks. |
michalvasko
approved these changes
Apr 10, 2024
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.
In the
test_ch
test, thetest_nc_ch_tls
case would result in the following report:The
pthread_cond_destroy(3p)
documentation says that:Let's make sure that this is the case by locking the associated mutex.