Skip to content

caddyhttp: Only attempt to enable full duplex for HTTP/1.x #6102

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

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Feb 13, 2024

When trying to enable full duplex for HTTP/2, the warning log was causing a panic because accessLogger references an expired pointer to the request, I think.

2024/02/13 09:49:06.567	DEBUG	http.stdlib	http2: panic serving 127.0.0.1:48350: runtime error: invalid memory address or nil pointer dereference
goroutine 78 [running]:
golang.org/x/net/http2.(*serverConn).runHandler.func1()
	/home/francis/go/pkg/mod/golang.org/x/[email protected]/http2/server.go:2361 +0x145
panic({0x17c9de0?, 0x2bb1fe0?})
	/usr/local/go1.22.0.linux-amd64/src/runtime/panic.go:770 +0x132
go.uber.org/zap.(*Logger).check(0x0, 0x1, {0x1a543e7, 0x1c})
	/home/francis/go/pkg/mod/go.uber.org/[email protected]/logger.go:330 +0x5e
go.uber.org/zap.(*Logger).Warn(0x1ef3c20?, {0x1a543e7?, 0x1a67a88?}, {0xc0004c4080, 0x1, 0x1})
	/home/francis/go/pkg/mod/go.uber.org/[email protected]/logger.go:253 +0x38
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc00026d8c8, {0x1f052a0, 0xc00068a008}, 0xc000428d80)
	/home/francis/repos/caddy/modules/caddyhttp/server.go:309 +0x6ea
net/http.serverHandler.ServeHTTP({0x0?}, {0x1f052a0?, 0xc00068a008?}, 0x0?)
	/usr/local/go1.22.0.linux-amd64/src/net/http/server.go:3137 +0x8e
net/http.initALPNRequest.ServeHTTP({{0x1f089c8?, 0xc000770a20?}, 0xc0001b9508?, {0xc0004d0000?}}, {0x1f052a0, 0xc00068a008}, 0xc000428d80)
	/usr/local/go1.22.0.linux-amd64/src/net/http/server.go:3745 +0x231
golang.org/x/net/http2.(*serverConn).runHandler(0x0?, 0x0?, 0x0?, 0x41baad?)
	/home/francis/go/pkg/mod/golang.org/x/[email protected]/http2/server.go:2368 +0xbb
created by golang.org/x/net/http2.(*serverConn).scheduleHandler in goroutine 115
	/home/francis/go/pkg/mod/golang.org/x/[email protected]/http2/server.go:2303 +0x21d

Simple fix, just need to only attempt it for HTTP/1.1, and using s.logger instead to avoid referencing the request.

@francislavoie francislavoie added the bug 🐞 Something isn't working label Feb 13, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Feb 13, 2024
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Thanks for the patch.

@francislavoie francislavoie merged commit 2c48dda into master Feb 13, 2024
@francislavoie francislavoie deleted the fix-full-duplex branch February 13, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants