runtime: print register state for all crashes (user panics, ...) #50294
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
See https://go.dev/play/p/ttzSoVd57ts?v=gotip
It crashes (due to nil dereference) as follows:
What did you expect to see?
Context: internal ABI specification
I expected to be able to see at least one of the input arguments to the crashing function
Square()
as they are still live. At the point of the crash, theRAX
register used to pass the first parameter has been clobbered, but its state gives valuable input about what the original value of the first parameter was. The second parameter can be found inRBX
untouched.The disassembly is as follows (truncated, annotated):
The same thing happens when using an actual panic to force a crash, but at least there we can see that the registers are being clobbered (annotated):
What did you see instead?
I expected that the parameter values in the stack trace would be as accurate as they could be, or at least more accurate than they are now. Now they contain values that aren't in any way related to the code that was running. The signal handler (likely) clobbers the registers state, which is why I believe we see values like
0x4046d9?, 0x60?, 0x0?
. We can see the same values if we callpanic()
manually.I've been told it would be a more involved project to improve the stack printer in such a way that it could take into account (better) the liveness, clobber state et cetera to get the "best possible estimate" for the parameter value. But a cheaper solution that would serve well in the interim would be to just dump the register state (all registers) when handling a crash. Then, a crash investigator can combine this information with an
objdump
to figure out whatever possible about the state of the crashing stack.An argument raised was that dumping register state would be scary to users. Some counterpoints:
cc @cherrymui @aclements who I've talked to about this.
The text was updated successfully, but these errors were encountered: