-
Notifications
You must be signed in to change notification settings - Fork 11
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
tests/optional_mutex: check counter within a lock #507
Conversation
I'm estimating that there's an 80% chance you decline this PR. Coverity-scan complains about this; we could change the code, or mark it as "false positive". The variables |
It's good "lock hygiene" to do this. I would be very surprised if any system implemented lock-free pthread_join, but theoretically even though a thread has exited we can't guarantee that values it has written to memory are visible to us until we acquire a lock. |
b3d47f0
to
092b02c
Compare
tests/optional_mutex/main.c
Outdated
if ((value == 0) && (counter == counter_expected)) | ||
rc = 0; | ||
else | ||
rc = 1; |
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.
Umm, what happens to this value on line 117?
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.
Right. I fixed this by going back to having an int match
.
db4f63a
to
f676d7f
Compare
40d0d7b
to
48302fe
Compare
48302fe
to
21f7048
Compare
9daf04c
to
f2c863c
Compare
f2c863c
to
8a14c0a
Compare
The variables "value" and "counter" are modified within mutex locks, so it's good "lock hygiene" to do the same for the final check. Reported by: Coverity scan
8a14c0a
to
463daa0
Compare
No description provided.