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

context: possible infinite recursion in Err()? #60139

Closed
aathan opened this issue May 12, 2023 · 1 comment
Closed

context: possible infinite recursion in Err()? #60139

aathan opened this issue May 12, 2023 · 1 comment

Comments

@aathan
Copy link

aathan commented May 12, 2023

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

$ go version
go version go1.19.3 linux/amd64

Does this issue reproduce with the latest release?

Cannot test this easily.

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

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

What did you do?

I called runtime.Stack() and saw:

goroutine 1299607 [runnable]:
context.(*valueCtx).Err(0xc00a52c3c0?)
	<autogenerated>:1 +0x3e
context.(*valueCtx).Err(0x48860a?)
	<autogenerated>:1 +0x2a
context.(*valueCtx).Err(0x48860a?)
	<autogenerated>:1 +0x2a
context.(*valueCtx).Err(0x48860a?)
	<autogenerated>:1 +0x2a
... repeats many many many times ...
...additional frames elided...
created by
....one_of_my_functions()
	somefile.go:2092 +0x4a5

What did you expect to see?

Not something that appears to be infinite recursion.

What did you see instead?

A very deep callstack that I cannot explain, particularly since the standard Err() function doesn't take a parameter. I haven't yet found the code for valueCtx but it didn't come up via definition link in vscode.

The app in question degrades in performance the longer it runs, and it appears this may be due to increasing load from some kind of processor heavy tight loop somewhere. So I went looking at stack traces and found the above oddity.

@seankhliao
Copy link
Member

There is no infinite recursion. Sounds more like you've created a very long chain of contexts in your app.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants