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

net/http: pc close panics #60862

Closed
Karitham opened this issue Jun 18, 2023 · 3 comments
Closed

net/http: pc close panics #60862

Karitham opened this issue Jun 18, 2023 · 3 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Karitham
Copy link

Karitham commented Jun 18, 2023

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

❯ go version
go version go1.20.4 linux/amd64

Does this issue reproduce with the latest release?

Yes, it reproduces with all the versions I tried, which include 1.20.5, 1.20.4 and 1.19.10

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

go env Output
❯ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kram/.cache/go-build"
GOENV="/home/kram/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/kram/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/kram/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/kram/dev/work/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/nix-shell.eWT3Zb/go-build726875218=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm running an HTTP server, read the request and respond to the request. The moment my handler exits. net/http panics.

It still writes the response back without issue, but the server panics after that and dies; it flushes the full response, has issues after that.

I'm having trouble reproducing the issue and debugging it properly, and can't find anything in my code that would relate to this.

The server is using ListenAndServe, like this

server := http.Server{
	Handler: router,
	Addr:    ":3804",
}

if err := server.ListenAndServe(); err != nil {
	panic(err) // never gets called
}

What did you expect to see?

My server staying alive, or maybe the stack trace pointing at something I am doing wrong.

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x9175dd]

goroutine 49 [running]:
net/http.(*persistConn).closeLocked(0xc00035a120, {0x27a2120, 0xc0000aac30})
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:2732 +0x21d
net/http.(*persistConn).close(0xc00035a120, {0x27a2120, 0xc0000aac30})
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:2717 +0xac
net/http.(*persistConn).readLoop.func1()
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:2075 +0x50
panic({0x21ef260, 0x32c2b30})
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/runtime/panic.go:890 +0x263
net/http.(*persistConn).Read(0xc00035a120, {0xc0004fc000, 0x1000, 0x1000})
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:1943 +0xea
bufio.(*Reader).fill(0xc0006d6660)
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/bufio/bufio.go:106 +0x2ab
bufio.(*Reader).Peek(0xc0006d6660, 0x1)
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/bufio/bufio.go:144 +0xd2
net/http.(*persistConn).readLoop(0xc00035a120)
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:2107 +0x2c8
created by net/http.(*Transport).dialConn
        /nix/store/kfpv1z26wn481yv5z1vzakla8fllhggn-go-1.20.4/share/go/src/net/http/transport.go:1765 +0x2586
exit status 2

Similar stack traces on all versions

@Karitham
Copy link
Author

After some more debugging, I've narrowed it down to an external package I'm using which seems to mess with net/http. I'm not sure net/http should panic like that though, I'll figure more of this with the related package.

riandyrn added a commit to riandyrn/try-otelchi-go120 that referenced this issue Jun 18, 2023
@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 19, 2023
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants
@gopherbot @seankhliao @Karitham and others