-
Notifications
You must be signed in to change notification settings - Fork 70
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
Remove trylock + unlock in acl_reset_condvar()
#279
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
See intel#276 for an explanation on why this needs to be done. In short, assuming library destructors work as we expect (i.e. they do not get called on abort), this code is unnecessary and can introduce undefined behavior. This will also fix the following Coverity issues: ``` lib/acl_threadsupport/test/acl_threadsupport_test.cpp:333:3: Type: Double unlock (LOCK) lib/acl_threadsupport/test/acl_threadsupport_test.cpp:332:3: 1. unlock: "acl_release_condvar" unlocks "cc.waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:375:5: 1.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/test/acl_threadsupport_test.cpp:333:3: 2. double_unlock: "acl_reset_condvar" unlocks "cc.waiter_mutex" while it is unlocked. lib/acl_threadsupport/src/acl_threadsupport.c:300:5: 2.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:301:5: 2.2. destroy: "pthread_mutex_destroy" destroys "C->waiter_mutex". lib/acl_threadsupport/test/acl_threadsupport_test.cpp:353:3: Type: Double unlock (LOCK) lib/acl_threadsupport/test/acl_threadsupport_test.cpp:345:3: 1. path: Condition "i < 10000000U /* COUNT */", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:346:5: 2. path: Condition "0 == i % (1000000U /* COUNT / 10 */)", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:352:3: 3. path: Jumping back to the beginning of the loop. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:345:3: 4. path: Condition "i < 10000000U /* COUNT */", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:346:5: 5. path: Condition "0 == i % (1000000U /* COUNT / 10 */)", taking false branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:351:5: 6. unlock: "acl_release_condvar" unlocks "cc.waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:375:5: 6.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/test/acl_threadsupport_test.cpp:352:3: 7. path: Jumping back to the beginning of the loop. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:345:3: 8. path: Condition "i < 10000000U /* COUNT */", taking false branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:353:3: 9. double_unlock: "acl_reset_condvar" unlocks "cc.waiter_mutex" while it is unlocked. lib/acl_threadsupport/src/acl_threadsupport.c:300:5: 9.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:301:5: 9.2. destroy: "pthread_mutex_destroy" destroys "C->waiter_mutex". lib/acl_threadsupport/test/acl_threadsupport_test.cpp:477:3: Type: Double unlock (LOCK) lib/acl_threadsupport/test/acl_threadsupport_test.cpp:464:3: 1. path: Condition "1 != acl_timed_wait_condvar(&cc, 1)", taking false branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:465:3: 2. path: Condition "1 != cc.timedout[0]", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:465:3: 3. path: Falling through to end of if statement. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:473:3: 4. path: Condition "0 != acl_timed_wait_condvar(&cc, 1)", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:473:3: 5. path: Falling through to end of if statement. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:474:3: 6. path: Condition "0 != cc.timedout[1]", taking true branch. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:474:3: 7. path: Falling through to end of if statement. lib/acl_threadsupport/test/acl_threadsupport_test.cpp:475:3: 8. unlock: "acl_release_condvar" unlocks "cc.waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:375:5: 8.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/test/acl_threadsupport_test.cpp:477:3: 9. double_unlock: "acl_reset_condvar" unlocks "cc.waiter_mutex" while it is unlocked. lib/acl_threadsupport/src/acl_threadsupport.c:300:5: 9.1. unlock: "pthread_mutex_unlock" unlocks "C->waiter_mutex". lib/acl_threadsupport/src/acl_threadsupport.c:301:5: 9.2. destroy: "pthread_mutex_destroy" destroys "C->waiter_mutex". ```
pcolberg
approved these changes
Feb 17, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @IlanTruanovsky for your detailed exploration! I will wait with the merge until integration passes.
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.
See #276 for an explanation on why this needs to be done.
In short, assuming library destructors work as we expect (i.e. they do not get called on abort), this code is unnecessary and can introduce undefined behavior.
This will also fix the following Coverity issues: