-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
unsafe.Pointer's rule 4 says:
Conversion of a Pointer to a uintptr when calling syscall.Syscall.
The Syscall functions in package syscall pass their uintptr arguments directly to the operating system, which then may, depending on the details of the call, reinterpret some of them as pointers. That is, the system call implementation is implicitly converting certain arguments back from uintptr to pointer.
It talks about "the Syscall functions", but on Windows, there's also Proc.Call and LazyProc.Call.
Q1: Are these two functions "Syscall functions"? Strictly speaking, I would interpret "Syscall functions" to mean Syscall{,6,9,12,15,18}. Perhaps the docs should be clarified.
Q2: Do functions have to be called directly, or are indirect calls allowed? The rule explicitly warns that conversions have to be performed directly in the argument list, but it doesn't say anything about indirect calls.
Q3: For Proc.Call and LazyProc.Call, are direct calls via method expressions allowed? E.g., if x.Call(uintptr(p), 0, 0)
is valid, then is (*Proc).Call(x, uintptr(p), 0, 0)
also valid?
Clarifying this is relevant to determining how far we need to go in fixing #34474.
Incidentally, Q2 and Q3 also apply to rule 5. The status quo there is that cmd/compile safely handles unsafe.Pointer(f(...))
for all f(...)
, so we do allow indirect and method expression calls to reflect.Value.Pointer and reflect.Value.UnsafeAddr.
/cc @rsc @ianlancetaylor
Metadata
Metadata
Assignees
Labels
Type
Projects
Status