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: regression where Func.Name panics on nil pointer #20872

Closed
dsnet opened this issue Jun 30, 2017 · 1 comment
Closed

runtime: regression where Func.Name panics on nil pointer #20872

dsnet opened this issue Jun 30, 2017 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Jun 30, 2017

On Go1.2 until Go1.8, the following would return an empty string:

(*runtime.Func)(nil).Name()

But a regression on Go1.9 (0efc8b2) causes this to panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x43ab52]

goroutine 1 [running]:
main.main()
	/tmp/sandbox221545061/main.go:7 +0x2a

It's probably worth keeping this behavior since a number of users blindly do runtime.FuncForPC(myPtr).Name() without checking that myPtr is non-nil.

\cc @aclements

@dsnet dsnet added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 30, 2017
@dsnet dsnet added this to the Go1.9 milestone Jun 30, 2017
@dsnet dsnet self-assigned this Jun 30, 2017
@gopherbot
Copy link

CL https://golang.org/cl/47354 mentions this issue.

@dsnet dsnet changed the title runtime: Func.Name panics on nil pointer runtime: regression where Func.Name panics on nil pointer Jul 10, 2017
@golang golang locked and limited conversation to collaborators Jul 10, 2018
@rsc rsc unassigned dsnet Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants