fmt: printing a map with unsafe.Pointer keys crashes #42622
Labels
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?darwin/amd64
, should be consistent for all platforms.go env
OutputWhat did you do?
This is the code for reproduce:
Here's the output:
What did you expect to see?
The behavior for storing values of same type (e.g.
reflect.Value
) should be consistent. Either it should reject storingreflect.Value
during compilation (since it containsunsafe.Pointer
that is non-comparable), or it should be able to correctly handlereflect.Value
as key.What did you see instead?
If multiple
reflect.Value
of same type being stored, it will panic when iterating the map keys (e.g. print the map). It would be nice to makeunsafe.Pointer
comparable just likeuintptr
to mitigate the issue.Similar to #33610
The text was updated successfully, but these errors were encountered: