Closed dvyukov closed 9 years ago
The variable is converted ti pid later: pid := int(uintptr(unsafe.Pointer(o))) Also now I am puzzled with this code: var o *syscall.Overlapped for { err := syscall.GetQueuedCompletionStatus(iocp, &code, &key, &o, syscall.INFINITE) Why do we pass **syscall.Overlapped to GQCS? Shouldn't it be *syscall.Overlapped?
http://msdn.microsoft.com/en-gb/library/windows/desktop/aa364986(v=vs.85).aspx suggests that it's meant as a pointer reference.
This should do it. right? There's still the unfortunate situation of GQCS being able to write both a pointer and a value to memory. Could/should we change the overlapped arg to be *uintptr? diff -r 17ba03832124 driver/driver_windows.go --- a/driver/driver_windows.go Sat Sep 13 09:10:35 2014 -0700 +++ b/driver/driver_windows.go Thu Oct 02 13:47:15 2014 +0100 @@ -94,9 +94,10 @@ // Read Job notifications about new "child" processes and collect them in childProcesses. go func() { var code, key uint32 - var o *syscall.Overlapped + var o uintptr + oa := (**syscall.Overlapped)(unsafe.Pointer(&o)) for { - err := syscall.GetQueuedCompletionStatus(iocp, &code, &key, &o, syscall.INFINITE) + err := syscall.GetQueuedCompletionStatus(iocp, &code, &key, oa, syscall.INFINITE) if err != nil { log.Printf("GetQueuedCompletionStatus failed: %v", err) return @@ -105,7 +106,7 @@ panic("Invalid GetQueuedCompletionStatus key parameter") } if code == JOB_OBJECT_MSG_NEW_PROCESS { - pid := int(uintptr(unsafe.Pointer(o))) + pid := int(o) if pid == syscall.Getpid() { continue }
CL https://golang.org/cl/152860043 mentions this issue.