-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/windows: clarify safety of Proc.Call, LazyProc.Call #42680
Comments
I think this is Q1 of #34684. |
Also, |
Yeah, this could be closed as a dup of #34684 I suppose. But I'm not exactly sure the status of that bug. It sure sounds like {Lazy,}Proc.Call just aren't safe to use today, at least for arguments involving pointers. Should we clarify that in the docs for now while we wait for something to happen with #34684? |
Direct calls to {Lazy,}Proc.Call should be fine, at least since b3bd7ab (first included in Go 1.14). Either way, I'm happy to have the docs clarified. |
Ah! I had just missed the I'll send some docs, thanks! |
…ntptrescapes The unofficial documentation for this pragma can be found in the source code: * https://github.com/golang/go/blob/go1.17.6/src/cmd/compile/internal/noder/lex.go#L71-L81 Instead of relying on this pragma, generic-worker now calls syscall.Syscall<x> directly. This change has been made since I suspect that nested go:uintptrescapes functions may not work as expected, but furthmore, since this pragma is not an official feature, it presumably may change over time, so we probably should not assume it will always be supported. There have also been several issues raised against functions and methods that rely on its behaviour, so it is not clear whether it is entirely safe to use: * golang/go#16035 * golang/go#23045 * golang/go#34474 * golang/go#34642 * golang/go#34684 * golang/go#34810 * golang/go#42680 Note, in future an option might be to generate the function bodies using mkwinsyscall: * https://github.com/golang/go/blob/go1.17.6/src/internal/syscall/windows/mksyscall.go#L9 * https://github.com/golang/go/blob/go1.17.6/src/syscall/mksyscall_windows.go#L47 * https://pkg.go.dev/golang.org/x/sys/windows/mkwinsyscall * https://github.com/golang/sys/blob/master/windows/mkwinsyscall/mkwinsyscall.go One advantage of this approach is that we can probably log the syscalls again using: * https://github.com/golang/sys/blob/50617c2ba19781ae46f34bb505064996b8fa32e8/windows/mkwinsyscall/mkwinsyscall.go#L43-L44 Alternatively if tracing doesn't do what we expect, we could write our own generator.
https://godoc.org/golang.org/x/sys/windows#LazyProc.Call and https://godoc.org/golang.org/x/sys/windows#Proc.Call are syscall.SysCall wrappers but take a bunch of uintptrs.
I assume that those wrappers are not covered by the uintptr(unsafe.Pointer) conversion exception number (4) from https://golang.org/pkg/unsafe/#Pointer, correct?
Could we document that either way in x/sys/windows?
I assume that many callers will require runtime.KeepAlive?
/cc @ianlancetaylor @mdempsky @alexbrainman @josharian @crawshaw
The text was updated successfully, but these errors were encountered: