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: crash shows autogenerated type parameters #48578

Closed
rsc opened this issue Sep 23, 2021 · 4 comments
Closed

runtime: crash shows autogenerated type parameters #48578

rsc opened this issue Sep 23, 2021 · 4 comments

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Sep 23, 2021

I have a parameterized type named Treap[K, V].
Here's a crash:

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

goroutine 1 [running]:
math/big.(*Int).Cmp(0x30, 0x10aee80)
	/Users/rsc/go/src/math/big/int.go:328 +0x25
main.(*Treap[.shape.*uint8_0,.shape.*uint8_1]).Get(0x10d7ec0, 0xc0000c0570, 0xc0000d7d40)
	/Users/rsc/complex.go:145 +0x7b
main.explore(0x10d6500, 0xc0000ae008, 0x10b7929)
	/Users/rsc/complex.go:73 +0x4b
main.main()
	/Users/rsc/complex.go:51 +0x585

Note the main.(*Treap[.shape.*uint8_0,.shape.*uint8_1]).Get.

I understand why the name is needed in the binary, but it's not a great name to see in the stack trace.
It seems like we should probably elide that part, as in main.(*Treap[...]).Get,
or else make it more readable somehow.

/cc @randall77 @danscales

@rsc rsc added this to the Go1.18 milestone Sep 23, 2021
@danscales
Copy link

@danscales danscales commented Sep 24, 2021

Seems like a good suggestion.

I think this might be the first case where we slightly change a function name in a backtrace, rather than completely omit the function entry (as with wrappers). I guess maybe we can use the '...' as a good indication that the user that the name is not exactly what is in the binary (i.e. the user will see something different if they debug the crash in gdb). Or maybe we can think of some further way to highlight the change (something at the beginning of the line?).

Loading

@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 24, 2021

If we had access to the dictionary we could print the real type(s) the code is instantiated with, as if it was fully stenciled. That could be tough, though, as we'd need to keep the dictionary reference alive and in a known location.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 24, 2021

Change https://golang.org/cl/352118 mentions this issue: runtime: elide instantiated types in tracebacks

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 24, 2021

Change https://golang.org/cl/352119 mentions this issue: cmd/compile: leave dictionary argument out of traceback argument list

Loading

@gopherbot gopherbot closed this in a80cbc2 Sep 27, 2021
gopherbot pushed a commit that referenced this issue Sep 27, 2021
The dictionary argument is implicit; the user doesn't need to see it.

Update #48578

Change-Id: I367ba4b6622119d3e01aaded90463d16823915a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/352119
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants