Open
Description
Consider the following program:
package main
var f func(int)
//go:nosplit
func x(y int) { f(y+1) }
func main() {
f = x
f(0)
}
When run, this program segfaults. This is because taking the address of a nosplit function completely avoids the linker's nosplit stack size check, meaning that this program very quickly exausts g0's stack and does a hard segfault.
All that this program prints is signal: segmentation fault
, and occasionally random debugging spew before the runtime kills itself.
I think this is a good case for making using nosplit require import "unsafe"
, because I can't see another way to fix this without violating the "calling a nosplit functions does not preempt" invariant.