Crash the GC with Random Values in Unsafe.Pointers

The author discusses the idea of storing non-pointer values in unsafe.Pointer variables, exploring whether it could cause issues with Go’s garbage collector. Despite warnings, tests show that it does not crash immediately, but storing certain memory addresses can lead to a panic. The author advises against using unsafe.Pointer unless necessary, cautioning against keeping values around and recommending only storing memory addresses, preferably those allocated outside of the Go runtime. The key takeaway is to handle unsafe.Pointer with care to avoid potential future issues. The content explores the nuances of memory handling in Go, revealing insights into the dangers of improper use.

https://philpearl.github.io/post/dumb_ways_to_die_random_pointers/

To top