Skip to content

x/net/http2/h2c panic #67168

Closed
Closed
@chenjie199234

Description

@chenjie199234

Go version

Go Version:1.22.2
build host:windows/amd64
build target:linux/amd64
run host:linux/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
go: stripping unprintable or unescapable characters from %"GOBIN"%
set GOBIN=C:\Users\������\Desktop\Go\bin
go: stripping unprintable or unescapable characters from %"GOCACHE"%
set GOCACHE=C:\Users\������\Desktop\Go\cache
go: stripping unprintable or unescapable characters from %"GOENV"%
set GOENV=C:\Users\������\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
go: stripping unprintable or unescapable characters from %"GOMODCACHE"%
set GOMODCACHE=C:\Users\������\Desktop\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
go: stripping unprintable or unescapable characters from %"GOPATH"%
set GOPATH=C:\Users\������\Desktop\Go
set GOPRIVATE=
set GOPROXY=direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
go: stripping unprintable or unescapable characters from %"GOGCCFLAGS"%
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\������\AppData\Local\Temp\go-build1138275416=/tmp/go-build -gno-record-gcc-switches

What did you do?

use x/net/h2c to start a h2c http server

h2c.NewHandler(r, &http2.Server{
	NewWriteScheduler:         func() http2.WriteScheduler { return http2.NewPriorityWriteScheduler(nil) },
	IdleTimeout:               time.Second * 5,
	MaxDecoderHeaderTableSize: 2048,
	MaxEncoderHeaderTableSize: 2048,
})

What did you see happen?

http: panic serving xxx.xxx.xxx.xxx:xxx: runtime error: invalid memory address or nil pointer dereference
goroutine 1028135 [running]:
net/http.(*conn).serve.func1()
	C:/Program Files/Go/src/net/http/server.go:1898 +0xbe
panic({0x1a14840?, 0x2dc6780?})
	C:/Program Files/Go/src/runtime/panic.go:770 +0x132
time.(*Timer).Reset(0x1a06a40?, 0xc00024dc50?)
	C:/Program Files/Go/src/time/sleep.go:135 +0xe
golang.org/x/net/http2.(*serverConn).closeStream(0xc00033ed00, 0xc0004d43c0, {0x1f847e0, 0x2dc8b20})
	C:/Users/陈杰/Desktop/Go/pkg/mod/golang.org/x/net@v0.24.0/http2/server.go:1642 +0x17b
golang.org/x/net/http2.(*serverConn).closeAllStreamsOnConnClose(0xc00033ed00)
	C:/Users/陈杰/Desktop/Go/pkg/mod/golang.org/x/net@v0.24.0/http2/server.go:862 +0xaa
golang.org/x/net/http2.(*serverConn).serve(0xc00033ed00)
	C:/Users/陈杰/Desktop/Go/pkg/mod/golang.org/x/net@v0.24.0/http2/server.go:919 +0x6ea
golang.org/x/net/http2.(*Server).ServeConn(0xc0004e2be0, {0x1fa57b0, 0xc0003c8018}, 0xc0005239b0)
	C:/Users/陈杰/Desktop/Go/pkg/mod/golang.org/x/net@v0.24.0/http2/server.go:532 +0xbad
golang.org/x/net/http2/h2c.h2cHandler.ServeHTTP({{0x1f85380?, 0xc0002513e0?}, 0xc0004e2be0?}, {0x1f92380, 0xc000134620}, 0xc0001c0240)
	C:/Users/陈杰/Desktop/Go/pkg/mod/golang.org/x/net@v0.24.0/http2/h2c/h2c.go:116 +0x649
net/http.serverHandler.ServeHTTP({0xc00024dad0?}, {0x1f92380?, 0xc000134620?}, 0x6?)
	C:/Program Files/Go/src/net/http/server.go:3137 +0x8e
net/http.(*conn).serve(0xc00015ee10, {0x1f9f2a0, 0xc00024da70})
	C:/Program Files/Go/src/net/http/server.go:2039 +0x5e8
created by net/http.(*Server).Serve in goroutine 58
	C:/Program Files/Go/src/net/http/server.go:3285 +0x4b4

What did you expect to see?

no panic

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions