syscall: SyscallN always escapes the variadic argument #70197
Closed
Description
Go version
go version devel go1.24-bea9b91f0f Tue Nov 5 01:16:03 2024 +0000 windows/amd64
What did you do?
Run go build -gcflags=-m .
package main
import (
"syscall"
"unsafe"
)
var sink byte
var procProcessPrng = syscall.NewLazyDLL("bcryptprimitives.dll").NewProc("ProcessPrng").Addr()
func main() {
var buf [10]byte
syscall.SyscallN(procProcessPrng, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)))
sink ^= buf[0]
}
What did you see happen?
The syscall.SyscallN
variadic argument escaped to the heap.
./main.go:13:18: ... argument escapes to heap
What did you expect to see?
The syscall.SyscallN
variadic argument didn't escape to the heap, just as other syscall.SyscalX
functions.
./main.go:13:18: ... argument does not escape
Note that syscall.SyscallN
is implemented by runtime.syscall_syscalln
, which makes sure that the variadic argument doesn't escape:
go/src/runtime/syscall_windows.go
Line 519 in bea9b91
@golang/compiler @golang/windows