Skip to content

syscall: SyscallN always escapes the variadic argument #70197

Closed
@qmuntal

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:

c.args = uintptr(noescape(unsafe.Pointer(&args[0])))

@golang/compiler @golang/windows

Metadata

Assignees

Labels

CriticalA critical problem that affects the availability or correctness of production systems built using GoNeedsFixThe path to resolution is known, but the work has not been done.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions