Commit 7ae35c100f for golang
commit 7ae35c100f633661447ce3864ec7c418e9bc10bc
Author: qmuntal <quimmuntal@gmail.com>
Date: Mon Nov 30 11:16:45 2026 +0100
syscall: avoid closing the job handle twice in TestJobHandle
TestJobHandle closes the job handle to terminate the child, then closes
it again on return. Windows can reuse the handle value during child.Wait
, so the deferred close can invalidate an unrelated runtime thread
handle.
Clear jobHandle after the explicit close, preserving the deferred
cleanup if the child fails to start.
Updates #80415
Change-Id: Ib858f04c7bbdff7f22d9780b16d46ea2345bfd34
Reviewed-on: https://go-review.googlesource.com/c/go/+/868381
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
diff --git a/src/syscall/exec_windows_test.go b/src/syscall/exec_windows_test.go
index f5d5cd0d65..b8edb3cf82 100644
--- a/src/syscall/exec_windows_test.go
+++ b/src/syscall/exec_windows_test.go
@@ -197,7 +197,11 @@ func TestJobHandle(t *testing.T) {
t.Run("Delete process", func(t *testing.T) {
jobHandle := createJobHandleToKillProcesses(t)
- defer syscall.Close(jobHandle)
+ defer func() {
+ if jobHandle != 0 {
+ syscall.CloseHandle(jobHandle)
+ }
+ }()
// start child
child, output := createTestJobChildCmd(t, []syscall.Handle{jobHandle})
@@ -208,6 +212,7 @@ func TestJobHandle(t *testing.T) {
// kill child
err = syscall.CloseHandle(jobHandle)
+ jobHandle = 0
if err != nil {
t.Fatalf("CloseHandle failed: %v", err)
}