Skip to content
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

os: missing conversion of internal/poll.ErrFileClosing to fs.ErrClosed #58622

Closed
nolta opened this issue Feb 21, 2023 · 2 comments
Closed

os: missing conversion of internal/poll.ErrFileClosing to fs.ErrClosed #58622

nolta opened this issue Feb 21, 2023 · 2 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.

Comments

@nolta
Copy link

nolta commented Feb 21, 2023

TL;DR: Posted to go-nuts, and Ian Lance Taylor responded:

I think this is a bug. (*File).readFrom, or perhaps NewSyscallError,
should convert poll.ErrFileClosing to os.ErrClosed, just as
(*File).wrapErr does.

I believe they're referring to this line in os/readfrom_linux.go.

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

$ go version
go version go1.18.10 linux/amd64

Does this issue reproduce with the latest release?

Don't know.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/runner/.cache/go-build"
GOENV="/home/runner/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/runner/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/runner/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/hostedtoolcache/go/1.18.10/x64"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/hostedtoolcache/go/1.18.10/x64/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.10"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/runner/work/gosh/gosh/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build918714692=/tmp/go-build -gno-record-gcc-switches"

What did you do?

My code is essentially running shell pipelines, and i want to catch harmless errors where a process on the left side of the pipeline dies because the right side has finished. Think { echo 1; echo 2; echo 3; } | head -n1.

So in addition to catching EPIPEs and SIGPIPEs, i catch file closed errors:

// ignore writes to closed pipe
switch err := err.(type) {
case *fs.PathError:
    if err.Op == "write" && err.Path == "|1" && errors.Is(err.Err, fs.ErrClosed) {
        return nil
    }
}
return err

What did you expect to see?

Nothing.

What did you see instead?

Code dies with the error message write |1: copy_file_range: use of closed file. Since this error appears to be internal/poll.ErrFileClosing, i can't catch it since i can't import the package.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 21, 2023
@thanm
Copy link
Contributor

thanm commented Feb 21, 2023

@golang/runtime

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Feb 21, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 21, 2023
@gopherbot
Copy link

Change https://go.dev/cl/469795 mentions this issue: os: use errors.Is instead of equality operator to determine poll.ErrFileClosing in File.wrapErr

@golang golang locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants