Skip to content

os: document concurrency properties for File methods #56043

Open
@bcmills

Description

@bcmills

What version of Go are you using (go version)?

https://pkg.go.dev/[email protected]

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/[email protected] 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.ExpertNeededNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions