-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: race detector in go1.11rc1 detects race with close(chan) and len(chan) #27070
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
Comments
Thanks for the bug report. Marking for 1.12 but it's OK with me if a clean fix goes into 1.11 or 1.11.1. I would guess that the problem has to do with the fact that len(chan) is inlined. That perhaps shouldn't happen when using the race detector. |
The race detector currently detects a race with len(chan) against close(chan). See: golang/go#27070 Skip the tests which trip this bug under the race detector.
The race detector currently detects a race with len(chan) against close(chan). See: golang/go#27070 Skip the tests which trip this bug under the race detector.
We unconditionally inline I'm not convinced this is a bug. The statement in the spec does not include As a practical matter, it is true that A simple fix would be to not use the address of |
Change https://golang.org/cl/135698 mentions this issue: |
@randall77 wrote:
I think that any channel operations causing the race detector to moan is surprising. IMHO the spec should be tightened to include
That seems like the right direction to go in to me. If it isn't a race then the race detector shouldn't be reporting it IMHO! |
@randall77 should we backport this to Go1.11.1? |
Not sure. I'll open an issue so we can discuss. Gopherbot, please open a backport to 1.11. |
Hmmm... gopherbot didn't open a CL. |
@randall77 FYI you have to @-mention gopherbot. In your text it didn’t have the |
What version of Go are you using (
go version
)?go version go1.11rc1 linux/amd64
Does this issue reproduce with the latest release?
It reproduces with go1.11rc1. It appears to be a regression as go1.10.1 does not have the same problem.
There doesn't appear to be any further commits to release-branch.go1.11 to try.
I tried go-tip
go version devel +714c141c4f Sat Aug 18 03:02:40 2018 +0000 linux/amd64
also with the same results.What operating system and processor architecture are you using (
go env
)?What did you do?
Save this program to
race.go
: https://play.golang.org/p/wBrXZ2n9BtWrun it with
go run -race race.go
What did you expect to see?
What did you see instead?
Discussion
The attached program races
close(chan)
againstlen(chan)
. In go1.10.1 this does not cause the race detector to fire. In go1.11rc1 it does.I believe this to be a regression since it says in
https://golang.org/ref/spec#Channel_types
(emphasis mine)
Which implies to me that
len()
should be usable without further synchronization. Though it doesn't explicitly say aboutclose()
so I guess there is some wriggle room.To have any of the operations on channels able to cause a race is surprising to me.
A bit of
git bisect
indicates that this is the commit where the problem started:17df5ed is the first bad commit by @mdempsky
The text was updated successfully, but these errors were encountered: