You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ReadMemStats has no other way to report an error, so it has to use a panic for that. This is how the stdlib works in situations like this. For example: https://go.dev/play/p/1_QJli64K6M .
The stack trace is a bit confusing, as there's a stack switch in there. Maybe we could have ReadMemStats do a quick nil check before stack switching, so it is obvious what is at the top of stack when the nil pointer dereference happens.
(Note that there is special code to hide unexported runtime frames from tracebacks. That code isn't relevant here because exported functions like ReadMemStats are excepted.)
Hi thanks for the response, sorry if I am misunderstanding you, but currently ReadMemStats doesn't panic, it just Segfaults without any special panic message. This is not like the other example in your go.dev link.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Reproduces on the most recent developer release branch, can see the later go-playground link
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
using
runtime.ReadMemStats
with nil pointer leads to segmentation fault without nice crash messagego.dev link to reproduce.
What did you expect to see?
A runtime panic message (i.e.
panic: runtime error: invalid memory address or nil pointer dereference
)What did you see instead?
The text was updated successfully, but these errors were encountered: