-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/race: os.File.ReadAt defeats race detector #51618
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
Quick investigation by @ericlagergren suggests that syscall.Pread (and Pwrite) are missing the required runtime calls, unlike Read and Write. |
Thanks for the analysis. |
Change https://go.dev/cl/391954 mentions this issue: |
Change https://go.dev/cl/392774 mentions this issue: |
For #51618 Fixes #51673 Change-Id: Ie63408d62303293d80afed8d5cf1cb164a8abecc Reviewed-on: https://go-review.googlesource.com/c/go/+/392774 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
Change https://go.dev/cl/392794 mentions this issue: |
Change https://go.dev/cl/392814 mentions this issue: |
Follow CL 392774 which changed Windows ReadFile and WriteFile in package syscall. For golang/go#51618 Change-Id: I0f8046adb0f8145bd0775a3b5399647897cf19ce Reviewed-on: https://go-review.googlesource.com/c/sys/+/392814 Trust: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
Follow CL 391954 which changed Pread/Pwrite in package syscall. For golang/go#51618 Change-Id: Icc587c61f083886bb66ca96717f686f56b398e34 Reviewed-on: https://go-review.googlesource.com/c/sys/+/392794 Trust: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run
with
GORACE=halt_on_error=1 go run -race foo.go
What did you expect to see?
I expect the race detector to flag the race.
What did you see instead?
The race detector misses the race and we get an infinite stream of random bytes.
Using Read instead of ReadAt almost immediately flags the race. The issue isn't specific to the file being opened. It happens just the same with files in /proc or actual files on a hard drive.
/cc @golang/runtime
The text was updated successfully, but these errors were encountered: