driver: fix bad pointer on windows
Fixes golang/go#8848.
LGTM=daniel.morsing, alex.brainman
R=alex.brainman, daniel.morsing
CC=golang-codereviews
https://golang.org/cl/152860043
diff --git a/driver/driver_windows.go b/driver/driver_windows.go
index 8232e11..777bee7 100644
--- a/driver/driver_windows.go
+++ b/driver/driver_windows.go
@@ -94,9 +94,12 @@
// Read Job notifications about new "child" processes and collect them in childProcesses.
go func() {
var code, key uint32
- var o *syscall.Overlapped
+ // o is declared as uintptr because GetQueuedCompletionStatus
+ // stores process id into it. If we declare it as *overlapped,
+ // runtime stack copier will crash due to bogus pointer value.
+ var o uintptr
for {
- err := syscall.GetQueuedCompletionStatus(iocp, &code, &key, &o, syscall.INFINITE)
+ err := syscall.GetQueuedCompletionStatus(iocp, &code, &key, (**syscall.Overlapped)(unsafe.Pointer(&o)), syscall.INFINITE)
if err != nil {
log.Printf("GetQueuedCompletionStatus failed: %v", err)
return
@@ -105,7 +108,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
}