microsoft / go-winio

Win32 IO-related utilities for Go
MIT License
939 stars 181 forks source link

initIO() in file.go leaks goroutine #272

Open zllovesuki opened 1 year ago

zllovesuki commented 1 year ago

Discovered in unit testing:

--- PASS: TestPipe (2.89s)
PASS
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 18 in state syscall, locked to thread, with syscall.SyscallN on top of the stack:
goroutine 18 [syscall, locked to thread]:
syscall.SyscallN(0x443cbd?, {0xc000097e58?, 0xc000296b40?, 0xc000097f98?})
    C:/Program Files/Go/src/runtime/syscall_windows.go:557 +0x109
syscall.Syscall6(0xc00022c7e0?, 0x0?, 0x0?, 0x0?, 0x0?, 0xc0003841d8?, 0x0?, 0x0?)
    C:/Program Files/Go/src/runtime/syscall_windows.go:501 +0x50
github.com/Microsoft/go-winio.getQueuedCompletionStatus(0x0?, 0xc000097f64, 0xc000097f68, 0xc000097f78, 0xffffffff)
    C:/Users/Vendetta/go/pkg/mod/github.com/!microsoft/go-winio@v0.6.0/zsyscall_windows.go:376 +0x11f
github.com/Microsoft/go-winio.ioCompletionProcessor(0x0?)
    C:/Users/Vendetta/go/pkg/mod/github.com/!microsoft/go-winio@v0.6.0/file.go:172 +0xb0
created by github.com/Microsoft/go-winio.initIO
    C:/Users/Vendetta/go/pkg/mod/github.com/!microsoft/go-winio@v0.6.0/file.go:73 +0xa5
]
FAIL    kon.nect.sh/specter/tun/client  3.775s

It seems like there's no way for user code to close the ioCompletionProcessor() in initIO() manually. Is it possible to expose a method to shutdown the goroutine?