-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version)?
https://pkg.go.dev/os@go1.19.1
Does this issue reproduce with the latest release?
Yes.
What did you do?
For #50436, I'm attempting to unblock reads on a *File returned by os.Pipe while it is being read concurrently by a user-controlled goroutine. The user-controlled goroutine may legitimately call the Close method, and may expect to be able to access other methods (such as SetDeadline) via type-assertion.
What did you expect to see?
Given #6270, #7970, #9307, #17647 and https://go.dev/cl/65490, I expected the documentation for `*os.File to describe which methods are safe to invoke concurrently and under what conditions.
What did you see instead?
The only mention of concurrency I could find in https://pkg.go.dev/os@go1.19.1 says this:
Note: The maximum number of concurrent operations on a File may be limited by the OS or the system. The number should be high, but exceeding it may degrade performance or cause other issues.
That seems to imply that at least some of the File methods may be invoked concurrently, but isn't explicit about which ones.
I see unsynchronized writes in the Close implementation on both unix and plan9 (but maybe not windows?); it's not obvious to me which other methods are or aren't safe.
(CC @rsc @ianlancetaylor @robpike from previous *File race conditions.)