Skip to content
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

os/exec: TestContextCancel failures on plan9/amd64 #60793

Open
psilva261 opened this issue Jun 14, 2023 · 4 comments
Open

os/exec: TestContextCancel failures on plan9/amd64 #60793

psilva261 opened this issue Jun 14, 2023 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Plan9
Milestone

Comments

@psilva261
Copy link
Member

psilva261 commented Jun 14, 2023

#!watchflakes
post <- goos == "plan9" && pkg == "os/exec" && test == "TestContextCancel"

The builder for plan9/amd64 fails e.g. with (log):

--- FAIL: TestContextCancel (60.31s)
panic: canceling context did not stop program [recovered]
	panic: canceling context did not stop program

goroutine 40 [running]:
panic({0x4ea3c0?, 0x5df740?})
	/tmp/workdir-gnot/go/src/runtime/panic.go:1017 +0x3a6 fp=0x480bfb88 sp=0x480bfad8 pc=0x237006
testing.tRunner.func1.2({0x4ea3c0, 0x5df740})
	/tmp/workdir-gnot/go/src/testing/testing.go:1545 +0x26f fp=0x480bfc38 sp=0x480bfb88 pc=0x2e234f
testing.tRunner.func1()
	/tmp/workdir-gnot/go/src/testing/testing.go:1548 +0x39d fp=0x480bfda0 sp=0x480bfc38 pc=0x2e1dbd
runtime.deferCallSave(0x480bfe58, 0x48149f90?)
	/tmp/workdir-gnot/go/src/runtime/panic.go:798 +0x84 fp=0x480bfdb0 sp=0x480bfda0 pc=0x236be4
runtime.runOpenDeferFrame(0x4801ef50)
	/tmp/workdir-gnot/go/src/runtime/panic.go:771 +0x1b8 fp=0x480bfdf0 sp=0x480bfdb0 pc=0x236a18
panic({0x4ea3c0?, 0x5df740?})
	/tmp/workdir-gnot/go/src/runtime/panic.go:914 +0x213 fp=0x480bfea0 sp=0x480bfdf0 pc=0x236e73
os/exec_test.TestContextCancel(0x4816ab60)
	/tmp/workdir-gnot/go/src/os/exec/exec_test.go:1006 +0x40f fp=0x480bff70 sp=0x480bfea0 pc=0x4c2b2f

It can be reproduced with

go test -v '-test.count=10' -test.run TestContextCancel

(At least the first test passes though)

It seems that the process isn't fully ready when cancel() gets called. (exec_test.go) One option could be to also read from stdout - although time.Sleep(time.Millisecond) seems to solve it as well.

@bcmills
Copy link
Contributor

bcmills commented Jun 14, 2023

It seems that the process isn't fully ready when cancel() gets called.

If that's the case, it's arguably a bug in os.StartProcess.

If (*exec.Cmd).Start returns a nil error (which has definitely already happened at that point in TestContextCancel), then it should be the case that the process has been created successfully — and can be terminated, and will break the StdinPipe connection when it dies.

@bcmills bcmills added this to the Backlog milestone Jun 14, 2023
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 14, 2023
@gopherbot
Copy link

Change https://go.dev/cl/503455 mentions this issue: os/exec: deflake TestContextCancel on plan9

@psilva261
Copy link
Member Author

If that's the case, it's arguably a bug in os.StartProcess.

That's true. The change above would only make the test pass.

(Related issue for NetBSD #58699)

@bcmills
Copy link
Contributor

bcmills commented Jun 14, 2023

(Related issue for NetBSD #58699)

FWIW, I think the NetBSD failures are probably a bug in either the NetBSD kernel or Go's use' of NetBSD system calls somewhere in syscall, os, or internal/poll. (And I'm pretty cranky that the NetBSD Go maintainers haven't looked into #57999 enough to diagnose it yet. 😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Plan9
Projects
Status: No status
Development

No branches or pull requests

3 participants