Skip to content

os: race between File.Close, File.Write, and other Opens #7970

Closed
@rsc

Description

@rsc
If you have a goroutine calling f.Close at the same time another calls f.Write, it can
happen that the f.Close happens, then an unrelated os.Open reuses the fd, then the
f.Write writes to the wrong fd. The timing would have to be just right, since Close does
set f.fd = -1, but it could happen.  We could decide this is not worth protecting
against, or we could introduce an rwlock on the File that must be rlocked across all
fd-using method implementations and wlocked by Close.

Investigate for 1.4.

Related to issue #5792.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions