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
sync/cond: redundant code in copyChecker.check #34516
Comments
Reviewed on https://codereview.appspot.com/11573043 . |
Note that |
This is how it works: First A - quick check that either pointer is not initialized (zero) or initialized to address different from its own (Cond was copied). On fastpath it fails, so it's all right for |
I suspect it's something like that, and the code should be left as it is. cc @dvyukov |
Originator's reasoning is as follows:
|
However, consider the following scenario: Two or more goroutines are using an uninitialized Cond so that their |
As suspected this is working as intended. Let's use #40924 to track the possibility of adding a comment. |
It adds two internal comments explaining why `c` is checked twice in a row and is intentional. There has been confusion about why this was done, confusion should not occur anymore: - golang#34516 - golang#40924
Change https://golang.org/cl/253378 mentions this issue: |
the copy chcker implementation (src/sync/cond.go,line :81)
the code
uintptr(*c) != uintptr(unsafe.Pointer(c))
have twice in same if branch.The text was updated successfully, but these errors were encountered: