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/pprof: durationExceedsWriteTimeout check doesn't consider ResponseController.SetWriteDeadline #64516

Closed
sentriz opened this issue Dec 2, 2023 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@sentriz
Copy link

sentriz commented Dec 2, 2023

Go version

go version go1.21.4 linux/amd64

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

$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/senan/.cache/go-build'
GOENV='/home/senan/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/senan/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/senan/.local/share/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/go'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local+path'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
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-build1962473061=/tmp/go-build -gno-record-gcc-switches'

What did you do?

curling the following program with

curl "http://localhost:8080/debug/pprof/profile?seconds=10"

(10 seconds being longer than the 1 second global WriteTimeout, but before than the deadline set by SetWriteDeadline)

https://go.dev/play/p/zWTDhWFutKP

package main

import (
	"fmt"
	"net/http"
	"net/http/pprof"
	"time"
)

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/debug/pprof/profile", func(w http.ResponseWriter, r *http.Request) {
		rc := http.NewResponseController(w)
		rc.SetWriteDeadline(time.Time{}) // no deadline
		pprof.Profile(w, r)
	})

	server := http.Server{
		Addr:         ":8080",
		WriteTimeout: 1 * time.Second, // 1 second timeout
		Handler:      mux,
	}

	fmt.Println(server.ListenAndServe())
}

What did you expect to see?

the request succeeds

What did you see instead?

HTTP 400 with "profile duration exceeds server's WriteTimeout"

this makes it hard to expose custom pprof handlers with global server write timeouts

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 2, 2023
@seankhliao
Copy link
Member

Duplicate of #62358

@seankhliao seankhliao marked this as a duplicate of #62358 Dec 2, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants