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: Frames example does not produce documented output #70057

Closed
jimmyfrasche opened this issue Oct 25, 2024 · 3 comments
Closed

runtime: Frames example does not produce documented output #70057

jimmyfrasche opened this issue Oct 25, 2024 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation Issues describing a change to documentation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@jimmyfrasche
Copy link
Member

Go version

go version go1.23.2 linux/amd64

Output of go env in your module/workspace:

Ran on the playground and locally

What did you do?

Run the example at https://pkg.go.dev/runtime#example-Frames

What did you see happen?

It outputs only - more:true | runtime.Callers

Commenting out the check that frame.File contains "runtime/" shows the missing frames and more.

What did you expect to see?

The same output that the example shows before it is run:

- more:true | runtime.Callers
- more:true | runtime_test.ExampleFrames.func1
- more:true | runtime_test.ExampleFrames.func2
- more:true | runtime_test.ExampleFrames.func3
- more:true | runtime_test.ExampleFrames
@gopherbot gopherbot added compiler/runtime Issues related to the Go compiler and/or runtime. Documentation Issues describing a change to documentation. labels Oct 25, 2024
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@adonovan
Copy link
Member

The issue here is that the formatting done to turn the code into an example changes its behavior: when run as a test, the stack includes these functions:

runtime.Callers
runtime_test.ExampleFrames.func1
runtime_test.ExampleFrames.func2
runtime_test.ExampleFrames.func3
runtime_test.ExampleFrames
testing.runExample
testing.runExamples
testing.(*M).Run
runtime_test.TestMain
main.main

but when the documentation Example is run as shown, the stack instead has these functions:

runtime.Callers
main.main.func1
main.main.func2
main.main.func3
main.main
runtime.main
runtime.goexit

Doing a replace-all from "main.main" to "runtime_test.ExampleFrames" before printing each line of output, and breaking after "main.main" is seen, should fix it.

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 28, 2024
@cagedmantis cagedmantis added this to the Backlog milestone Oct 28, 2024
@mknyszek mknyszek added the Suggested Issues that may be good for new contributors looking for work to do. label Oct 30, 2024
callthingsoff added a commit to callthingsoff/go that referenced this issue Nov 9, 2024
Fixes golang#70057

Change-Id: I286822f844fcb95fa8b55bfc30fe472d0ba11de0
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/625904 mentions this issue: runtime: fix ExampleFrames to produce documented output in main func

callthingsoff added a commit to callthingsoff/go that referenced this issue Nov 9, 2024
Fixes golang#70057

Change-Id: I286822f844fcb95fa8b55bfc30fe472d0ba11de0
callthingsoff added a commit to callthingsoff/go that referenced this issue Nov 11, 2024
Fixes golang#70057

Change-Id: I286822f844fcb95fa8b55bfc30fe472d0ba11de0
callthingsoff added a commit to callthingsoff/go that referenced this issue Nov 12, 2024
Fixes golang#70057

Change-Id: I286822f844fcb95fa8b55bfc30fe472d0ba11de0
@github-project-automation github-project-automation bot moved this from Todo to Done in Go Compiler / Runtime Nov 14, 2024
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. Documentation Issues describing a change to documentation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Suggested Issues that may be good for new contributors looking for work to do.
Projects
Development

Successfully merging a pull request may close this issue.

6 participants