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
{{ message }}
This repository was archived by the owner on Oct 21, 2025. It is now read-only.
If any type containing a pointer is stored in the arena, the data it points to may be garbage collected if no other pointers exist because the GC cannot know about those pointers as the slabs are allocated without type information. This leads to UB when those pointers are dereferenced.
package main
import (
"fmt""runtime""github.com/ortuman/nuke"
)
funcmain() {
arena:=nuke.NewSlabArena(256*1024, 1)
varhomes []*stringfori:=0; i<1000; i++ {
home:= nuke.New[string](arena)
*home=fmt.Sprintf("this string contains the number %d in the middle", i)
ifi%10==0 {
runtime.GC()
}
homes=append(homes, home)
}
// All pointers stored in the arena are weak, and do not keep the data they// refer to alive; any pointed-to data may be garbage collected if no "real"// pointers to it exist.fori, home:=rangehomes {
fmt.Printf("%d: %q\n", i, *home)
}
}
If any type containing a pointer is stored in the arena, the data it points to may be garbage collected if no other pointers exist because the GC cannot know about those pointers as the slabs are allocated without type information. This leads to UB when those pointers are dereferenced.
https://go.dev/play/p/r4YNthSmv-4