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

Fix subtle potential race/panic in a test #276

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented Apr 8, 2024

In this CI run, there's a weird panic from a test where there is a race between the test function exiting and another goroutine trying to report an error using the function's *testing.T instance:
https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275

In case that link expires (or GitHub cleans up the log/output details at some point), here's the output:

panic: Fail in goroutine after TestPathological has completed

goroutine 343 [running]:
testing.(*common).Fail(0xc0001c7380)
	C:/hostedtoolcache/windows/go/1.[19](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:20).13/x64/src/testing/testing.go:824 +0xe5
testing.(*common).Fail(0xc0005104e0)
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:818 +0x47
testing.(*common).Errorf(0xc0005104e0, {0xab612a?, 0x7[20](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:21)f40?}, {0xc0001f7fc0?, 0x644f85?, 0x0?})
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:941 +0x65
github.com/bufbuild/protocompile/parser.TestPathological.func1.1()
	D:/a/protocompile/protocompile/parser/parser_test.go:1011 +0x6b
created by time.goFunc
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/time/sleep.go:176 +0x32
FAIL	github.com/bufbuild/protocompile/parser	1.189s

So this awkward change attempts to prevent the above panic.

@jhump jhump requested a review from emcfarlane April 10, 2024 16:47
@jhump jhump enabled auto-merge (squash) April 10, 2024 18:22
@jhump jhump merged commit 8785698 into main Apr 10, 2024
8 checks passed
@jhump jhump deleted the jh/fix-weird-panic-race-in-test branch April 10, 2024 18:23
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Apr 12, 2024
In a CI run, there was a weird panic from a test in which there was a race
between the test function exiting and another goroutine trying to report
an error using the function's `*testing.T` instance. This fixes that.

CI run:
https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275

Panic output:
```
panic: Fail in goroutine after TestPathological has completed

goroutine 343 [running]:
testing.(*common).Fail(0xc0001c7380)
	C:/hostedtoolcache/windows/go/1.[19](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:20).13/x64/src/testing/testing.go:824 +0xe5
testing.(*common).Fail(0xc0005104e0)
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:818 +0x47
testing.(*common).Errorf(0xc0005104e0, {0xab612a?, 0x7[20](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:21)f40?}, {0xc0001f7fc0?, 0x644f85?, 0x0?})
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:941 +0x65
github.com/bufbuild/protocompile/parser.TestPathological.func1.1()
	D:/a/protocompile/protocompile/parser/parser_test.go:1011 +0x6b
created by time.goFunc
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/time/sleep.go:176 +0x32
FAIL	github.com/bufbuild/protocompile/parser	1.189s
```

(cherry picked from commit 8785698)
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Apr 12, 2024
In a CI run, there was a weird panic from a test in which there was a race
between the test function exiting and another goroutine trying to report
an error using the function's `*testing.T` instance. This fixes that.

CI run:
https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275

Panic output:
```
panic: Fail in goroutine after TestPathological has completed

goroutine 343 [running]:
testing.(*common).Fail(0xc0001c7380)
	C:/hostedtoolcache/windows/go/1.[19](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:20).13/x64/src/testing/testing.go:824 +0xe5
testing.(*common).Fail(0xc0005104e0)
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:818 +0x47
testing.(*common).Errorf(0xc0005104e0, {0xab612a?, 0x7[20](https://github.com/bufbuild/protocompile/actions/runs/8606959743/job/23586468561?pr=275#step:7:21)f40?}, {0xc0001f7fc0?, 0x644f85?, 0x0?})
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/testing/testing.go:941 +0x65
github.com/bufbuild/protocompile/parser.TestPathological.func1.1()
	D:/a/protocompile/protocompile/parser/parser_test.go:1011 +0x6b
created by time.goFunc
	C:/hostedtoolcache/windows/go/1.19.13/x64/src/time/sleep.go:176 +0x32
FAIL	github.com/bufbuild/protocompile/parser	1.189s
```

(cherry picked from commit 8785698)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants