This patch to libgo fixes sigfwd to not allocate memory. The use of &[1]uintptr{fn} was causing memory allocation, even though it is being compiled for the runtime package. That is a bad idea for this function, which is invoked by a signal handler. Rewrite it to use only constructs that do not allocate memory when compiled for the runtime package.
The test for this is misc/cgo/testcarchive in the main repo, which we don't yet test. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 245776) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -0bcc1bc98dca48af40d9f54f4eacbbafaa30beb1 +e1502234b5011a1ab859519f1f217dbf4369ec9b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/signal_gccgo.go =================================================================== --- libgo/go/runtime/signal_gccgo.go (revision 245745) +++ libgo/go/runtime/signal_gccgo.go (working copy) @@ -127,9 +127,10 @@ func raiseproc(sig uint32) { //go:nosplit //go:nowritebarrierrec func sigfwd(fn uintptr, sig uint32, info *_siginfo_t, ctx unsafe.Pointer) { - f1 := &[1]uintptr{fn} - f2 := *(*func(uint32, *_siginfo_t, unsafe.Pointer))(unsafe.Pointer(&f1)) - f2(sig, info, ctx) + f1 := [1]uintptr{fn} + f2 := &f1 + f3 := *(*func(uint32, *_siginfo_t, unsafe.Pointer))(unsafe.Pointer(&f2)) + f3(sig, info, ctx) } //go:nosplit