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

testing: go test -parallel=N where N < 1 panics with a deadlock #20542

Closed
mvdan opened this issue May 31, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@mvdan
Copy link
Member

commented May 31, 2017

What version of Go are you using (go version)?

go version devel +32764f7726 Wed May 31 17:59:09 2017 +0100 linux/amd64

Also on 1.8.3.

What operating system and processor architecture are you using (go env)?

not relevant

What did you do?

While investigating #19280, I ran go test -parallel=0 and go test -parallel=-1 (on some trivial parallel tests) to see what would happen without any changes to the testing package.

What did you expect to see?

An error, like "N must be a positive integer".

What did you see instead?

 $ go test -v -parallel=0
=== RUN   TestParA
=== RUN   TestParB
=== RUN   TestParC
=== RUN   TestParC/C0
=== RUN   TestParC/C1
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
testing.(*T).Run(0xc420090000, 0x535462, 0x8, 0x53d5c0, 0x468801)
        /home/mvdan/tip/src/testing/testing.go:791 +0x2fc
testing.runTests.func1(0xc420090000)
        /home/mvdan/tip/src/testing/testing.go:1005 +0x6c
testing.tRunner(0xc420090000, 0xc42003bde8)
        /home/mvdan/tip/src/testing/testing.go:747 +0xd0
testing.runTests(0xc42000a060, 0x5dd6e0, 0x3, 0x3, 0xc4200443b0)
        /home/mvdan/tip/src/testing/testing.go:1003 +0x2c1
testing.(*M).Run(0xc42003bf20, 0xc42003bf78)
        /home/mvdan/tip/src/testing/testing.go:922 +0x111
main.main()
        _/home/mvdan/par/_test/_testmain.go:48 +0xdb

goroutine 5 [chan receive]:
testing.(*T).Parallel(0xc4200900f0)
        /home/mvdan/tip/src/testing/testing.go:677 +0x127
_/home/mvdan/par.TestParA(0xc4200900f0)
        /home/mvdan/par/f_test.go:6 +0x2b
testing.tRunner(0xc4200900f0, 0x53d5b0)
        /home/mvdan/tip/src/testing/testing.go:747 +0xd0
created by testing.(*T).Run
        /home/mvdan/tip/src/testing/testing.go:790 +0x2de

goroutine 6 [chan receive]:
testing.(*T).Parallel(0xc4200901e0)
        /home/mvdan/tip/src/testing/testing.go:677 +0x127
_/home/mvdan/par.TestParB(0xc4200901e0)
        /home/mvdan/par/f_test.go:11 +0x2b
testing.tRunner(0xc4200901e0, 0x53d5b8)
        /home/mvdan/tip/src/testing/testing.go:747 +0xd0
created by testing.(*T).Run
        /home/mvdan/tip/src/testing/testing.go:790 +0x2de

goroutine 7 [chan receive]:
testing.tRunner.func1(0xc4200902d0)
        /home/mvdan/tip/src/testing/testing.go:723 +0x13c
testing.tRunner(0xc4200902d0, 0x53d5c0)
        /home/mvdan/tip/src/testing/testing.go:749 +0xda
created by testing.(*T).Run
        /home/mvdan/tip/src/testing/testing.go:790 +0x2de

goroutine 8 [chan receive]:
testing.(*testContext).waitParallel(0xc42000e2d0)
        /home/mvdan/tip/src/testing/testing.go:834 +0x9f
testing.(*T).Parallel(0xc4200903c0)
        /home/mvdan/tip/src/testing/testing.go:678 +0x13f
_/home/mvdan/par.TestParC.func1(0xc4200903c0)
        /home/mvdan/par/f_test.go:18 +0x34
testing.tRunner(0xc4200903c0, 0xc420044450)
        /home/mvdan/tip/src/testing/testing.go:747 +0xd0
created by testing.(*T).Run
        /home/mvdan/tip/src/testing/testing.go:790 +0x2de

goroutine 9 [chan receive]:
testing.(*testContext).waitParallel(0xc42000e2d0)
        /home/mvdan/tip/src/testing/testing.go:834 +0x9f
testing.(*T).Parallel(0xc4200904b0)
        /home/mvdan/tip/src/testing/testing.go:678 +0x13f
_/home/mvdan/par.TestParC.func1(0xc4200904b0)
        /home/mvdan/par/f_test.go:18 +0x34
testing.tRunner(0xc4200904b0, 0xc420044490)
        /home/mvdan/tip/src/testing/testing.go:747 +0xd0
created by testing.(*T).Run
        /home/mvdan/tip/src/testing/testing.go:790 +0x2de
exit status 2
FAIL    _/home/mvdan/par        0.004s

The tests themselves are silly examples - this is reproducible with any set of parallel tests. If none of the tests call t.Parallel() the panic doesn't occur, supposedly because N isn't used at all.

I realise this is somewhat expected, but we should error instead of panicking. Happy to work on a CL if my thinking is correct.

/cc @mpvl @josharian

@mvdan mvdan self-assigned this May 31, 2017

@mvdan

This comment has been minimized.

Copy link
Member Author

commented May 31, 2017

Also worth noting that I likely don't want to make the flag.Int("test.parallel", ... a flag.Uint as I'll want to make use of -1 as a special value in #19280.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented May 31, 2017

Yes, I suppose an error is better than a panic.

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone May 31, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Aug 9, 2017

Change https://golang.org/cl/54150 mentions this issue: testing: error if -parallel is given N<1

@gopherbot gopherbot closed this in 86dde2d Aug 25, 2017

@golang golang locked and limited conversation to collaborators Aug 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.