weak: Pointer.Value() panics for zero-valued receivers #71153
Labels
BugReport
Issues describing a possible bug in the Go implementation.
NeedsFix
The path to resolution is known, but the work has not been done.
release-blocker
Milestone
What version of Go are you using (
go version
)?Also reproduces with tip.golang.org./play. (see below)
Does this issue reproduce with the latest release?
The
weak
package is new in go 1.24.What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I called
Value()
on a zero-valuedweak.Pointer
Simple repro:
https://go.dev/play/p/8StbfbJSHuw?v=gotip
Same for calling
weak.Make[...](nil)
: https://go.dev/play/p/J5sbsM-Xe3R?v=gotipWhat did you expect to see?
Per the documentation on
weak.Pointer
,weak.Pointer.Value()
should returnnil
, so the above repro should printnil
.This relevant doc-comment paragraph currently reads:
What did you see instead?
I received a segfault/panic within the runtime.
It appears that the panic is happening on this Load:
https://cs.opensource.google/go/go/+/master:src/runtime/mheap.go;l=2122;drc=a76cc5a4ecb004616404cac5bb756da293818469
It seems like there should be a
nil
check at the top ofinternal_weak_runtime_makeStrongFromWeak
before convertingu
to an*atomic.Uintptr
.The text was updated successfully, but these errors were encountered: