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

runtime: panic while panicking discards error message #52257

Closed
myaaaaaaaaa opened this issue Apr 10, 2022 · 6 comments
Closed

runtime: panic while panicking discards error message #52257

myaaaaaaaaa opened this issue Apr 10, 2022 · 6 comments
Labels
help wanted NeedsFix
Milestone

Comments

@myaaaaaaaaa
Copy link

@myaaaaaaaaa myaaaaaaaaa commented Apr 10, 2022

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

$ go version
go version go1.18 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2719610640=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.18 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.18
uname -sr: Linux 5.17.1-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.35.

What did you do?

#17671 fixed a hang caused by recursive panicking, but as a side effect, panic messages are now always discarded even if the recursion isn't endless. Is it feasible for the runtime to attempt to print the error even in the middle of a panic, and only stop after reaching a certain recursion depth?

Minimal example is available here: https://go.dev/play/p/IpGNUlM9YFP

What did you expect to see?

fatal error: panic while printing panic value: important error message

stack trace omitted...

What did you see instead?

fatal error: panic while printing panic value

stack trace omitted...
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 10, 2022

I don't see what the runtime can do with an example like that. It can't print the original panic value, because attempting to print it will itself panic. You seem to be suggesting that it should print it anyhow, but there is literally nothing to print. The attempt to find something to print failed.

@ianlancetaylor ianlancetaylor added the WaitingForInfo label Apr 10, 2022
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Apr 10, 2022

This seems to be asking for printing the second panic value?
Where first is panic(exampleError{}) and second is panic("important error message") that happens when trying to print the first panic.

@myaaaaaaaaa
Copy link
Author

@myaaaaaaaaa myaaaaaaaaa commented Apr 10, 2022

This seems to be asking for printing the second panic value? Where first is panic(exampleError{}) and second is panic("important error message") that happens when trying to print the first panic.

Yes, that's correct. Right now a workaround to get the second panic value printed is to do something like panic(fmt.Sprintf("%v", exampleError{}))

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 11, 2022

Ah, got it, thanks. Sorry for the confusion.

@ianlancetaylor ianlancetaylor added help wanted NeedsFix and removed WaitingForInfo labels Apr 11, 2022
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Apr 11, 2022
@myaaaaaaaaa
Copy link
Author

@myaaaaaaaaa myaaaaaaaaa commented Apr 12, 2022

No worries, it's admittedly a fairly bizarre scenario.

I've updated the playground link with a hopefully clearer explanation, copied here for convenience: https://go.dev/play/p/IpGNUlM9YFP

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 12, 2022

Change https://go.dev/cl/399874 mentions this issue: runtime: avoid panic while panicking discards error message

@dmitshur dmitshur removed this from the Backlog milestone Apr 15, 2022
@dmitshur dmitshur added this to the Go1.19 milestone Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix
Projects
None yet
Development

No branches or pull requests

5 participants