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

runtime: netpollBreak write failed with 1 #49674

Closed
zouyonghao opened this issue Nov 19, 2021 · 1 comment
Closed

runtime: netpollBreak write failed with 1 #49674

zouyonghao opened this issue Nov 19, 2021 · 1 comment

Comments

@zouyonghao
Copy link

@zouyonghao zouyonghao commented Nov 19, 2021

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

go version go1.17.2 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zyh/.cache/go-build"
GOENV="/home/zyh/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zyh/go_workspace/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zyh/go_workspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/zyh/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/zyh/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build3831048988=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Run etcd and the write syscall returns -1

What did you expect to see?

According to the man page of syscall write, it

On success, the number of bytes written is returned.  On error,
       -1 is returned, and errno is set to indicate the error.

So -1 is a common case for write, but the program fails in this case.

What did you see instead?

The runtime should handle this error, but the code in netpoll_epoll.go and netpoll_kqueue.go seems not.

n := write(netpollBreakWr, unsafe.Pointer(&b), 1)
if n == 1 {
break
}
if n == -_EINTR {
continue
}
if n == -_EAGAIN {
return
}
println("runtime: netpollBreak write failed with", -n)
throw("runtime: netpollBreak write failed")

The piece of code shows that it handles the return number of write, but it seems the return value can only be the length of write, which is 1 in this case, and -1 that indicates error. And we should use the errno to know what the error is.

@zouyonghao
Copy link
Author

@zouyonghao zouyonghao commented Nov 19, 2021

Oops, I forgot that go uses the raw system call which just returns the error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant