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: elided panic goroutine stack trace doesn't print "additional frames elided" since go1.8 #32383

Closed
maruel opened this issue Jun 2, 2019 · 5 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@maruel
Copy link
Contributor

maruel commented Jun 2, 2019

Repro

https://play.golang.org/p/zcDltp375Sf

package main

func recurse(i int) {
	if i > 0 {
		recurse(i - 1)
		return
	}
	panic(42)
}

func main() {
	recurse(100)
}

Or:

$ go get github.com/maruel/panicparse/cmd/panic
$ panic stack_cut_off

Expected

This is the case in go1.7.6:

(...)
main.recurse(0x61)
        /home/maruel/go/src/github.com/maruel/panicparse/cmd/panic/main.go:56 +0x33
main.recurse(0x62)
        /home/maruel/go/src/github.com/maruel/panicparse/cmd/panic/main.go:56 +0x33
...additional frames elided...

runtime/traceback.go#L751 is supposed to print("...additional frames elided...\n") when the stack trace is more than _TracebackMaxFrames, defined as 100 in runtime/runtime2.go#L786

Actual

It is not effective since go1.8.

(...)
main.recurse(0x61)
        /home/maruel/go/src/github.com/maruel/panicparse/cmd/panic/main.go:56 +0x33
main.recurse(0x62)
        /home/maruel/go/src/github.com/maruel/panicparse/cmd/panic/main.go:56 +0x33

Investigation

cat > ~/test_golang.sh <<EOF
#!/bin/bash
set -eu
cd ~/src/golang/src
./make.bash
go install github.com/maruel/panicparse/cmd/panic
panic stack_cut_off |& grep 'additional frames elided'
EOF
chmod +x ~/test_golang.sh

git bisect start go1.8 go1.7.6
git bisect run ~/test_golang.sh
git bisect reset

Found the culprit commit to be f9feaff reviewed at https://go-review.googlesource.com/c/go/+/33165/

@agnivade agnivade changed the title elided panic goroutine stack trace doesn't print "additional frames elided" since go1.8 runtime: elided panic goroutine stack trace doesn't print "additional frames elided" since go1.8 Jun 2, 2019
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 2, 2019
@agnivade
Copy link
Contributor

agnivade commented Jun 2, 2019

@ianlancetaylor @rsc

@gopherbot
Copy link

Change https://golang.org/cl/180077 mentions this issue: runtime: add back elided stack footer on traces of over 100 depth

@maruel
Copy link
Contributor Author

maruel commented Jun 2, 2019

While investigating, I realized that stack depth can expand well over 100 (is it due to compile time inlining?). Here's an interesting example: https://play.golang.org/p/lQ_TDHJjyUw

Also I think my "fix" is incorrect. Still investigating.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
@prattmic prattmic added this to the Backlog milestone Jul 13, 2022
@prattmic
Copy link
Member

I took a quick look today.

For this program, after the loop n = 100, nprint = 99. Likely because we skip printing one panic frame at the top?

@gopherbot
Copy link

Change https://go.dev/cl/468301 mentions this issue: runtime: delete gentraceback

@golang golang locked and limited conversation to collaborators Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants