Skip to content

net/http: panic in HTTP ResponseWriter #69744

Closed
@thierry-f-78

Description

@thierry-f-78

Go version

1.22.7 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/cache/go-mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.7'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -ffile-prefix-map=/tmp/go-build959956862=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I Use http handler to process homemade timeouts.

What did you see happen?

Description

A panic occurs in an http.ResponseWriter under specific conditions. The issue is inconsistent and difficult to reproduce reliably. It has been observed frequently on a colleague's PC and occasionally on other machines.

Reproducibility

  • Cannot be reproduced consistently
  • Never encountered on macOS ARM with the program compiled for ARM

Error Message

runtime error: invalid memory address or nil pointer dereference

Stack Trace

2024-10-01 15:59:30 goroutine 15523 [running]:
2024-10-01 15:59:30 runtime/debug.Stack()
2024-10-01 15:59:30     runtime/debug/stack.go:24 +0x5e
2024-10-01 15:59:30 server/pkg/sentry.Recover()
2024-10-01 15:59:30     server/pkg/sentry/sentry.go:50 +0x30a
2024-10-01 15:59:30 panic({0x1ecc0e0?, 0x39c4550?})
2024-10-01 15:59:30     runtime/panic.go:770 +0x132
2024-10-01 15:59:30 bufio.(*Writer).Write(0xc000fae000, {0xc000116000?, 0x456d8c?, 0xc00bf13fa0?})
2024-10-01 15:59:30     bufio/bufio.go:679 +0xe1
2024-10-01 15:59:30 net/http.(*response).write(0xc004e4cc40, 0x6340, {0xc000116000, 0x6340, 0x8000}, {0x0, 0x0})
2024-10-01 15:59:30     net/http/server.go:1658 +0x2fe
2024-10-01 15:59:30 net/http.(*response).Write(0x0?, {0xc000116000?, 0xc00c8e2601?, 0x1000000000001?})
2024-10-01 15:59:30     net/http/server.go:1616 +0x2a
2024-10-01 15:59:30 server/pkg/api/server.(*writeTimeoutHandler).Write.func1({0x29dcc50?, 0xc004e4cc40?})
2024-10-01 15:59:30     server/pkg/api/server/server.go:125 +0x8c
2024-10-01 15:59:30 created by server/pkg/api/server.(*writeTimeoutHandler).Write in goroutine 15134
2024-10-01 15:59:30     server/pkg/api/server/server.go:122 +0x1b2

What did you expect to see?

Maybe an error, or nothing, but not a panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions