Skip to content

go/analysis/passes/loopclosure: avoid panic in new parallel subtest check when t.Run has single argument #424

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

Closed
wants to merge 1 commit into from

Conversation

thepudds
Copy link
Contributor

@thepudds thepudds commented Jan 18, 2023

The new Go 1.20 parallel subtest check in the loopclosure pass
can panic in the rare case of t.Run with a single argument:

fn := func() (string, func(t *testing.T)) { return "", nil }
t.Run(fn())

A real-world example:

https://github.com/go-spatial/geom/blob/3cd2f5a9a082dd4f827c9f9b69ba5d736d2dcb12/planar/planar_test.go#L118

This has been present for multiple months without seeming to
be reported, so presumably this is a rare pattern.

Avoid that panic by checking t.Run has an expected number
of arguments.

Fixes golang/go#57908

@gopherbot
Copy link
Contributor

This PR (HEAD: 24e65a4) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/462282 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from thepudds:

Patch Set 1: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 2:

Kokoro presubmit build starting for golang/tools/gopls-legacy/presubmit
Logs at:
https://source.cloud.google.com/results/invocations/40fad090-609b-4c7c-9f48-5de3cd4f360b


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 2: gopls-CI+1

Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/40fad090-609b-4c7c-9f48-5de3cd4f360b


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 2: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462282.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Jan 18, 2023
…heck when t.Run has single argument

The new Go 1.20 parallel subtest check in the loopclosure pass
can panic in the rare case of t.Run with a single argument:

    fn := func() (string, func(t *testing.T)) { return "", nil }
    t.Run(fn())

A real-world example:

https://github.com/go-spatial/geom/blob/3cd2f5a9a082dd4f827c9f9b69ba5d736d2dcb12/planar/planar_test.go#L118

This has been present for multiple months without seeming to
be reported, so presumably this is a rare pattern.

Avoid that panic by checking t.Run has an expected number
of arguments.

Fixes golang/go#57908

Change-Id: I5cde60edf624e16bb9f534e435bcd55e63a15647
GitHub-Last-Rev: 24e65a4
GitHub-Pull-Request: #424
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462282
Run-TryBot: thepudds <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
Auto-Submit: Russ Cox <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
gopls-CI: kokoro <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 1:

Kokoro presubmit build starting for golang/tools/gopls-legacy/presubmit
Logs at:
https://source.cloud.google.com/results/invocations/5280d17a-f210-43dc-b69e-87b6d0c07b2c


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 1: gopls-CI+1

Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/5280d17a-f210-43dc-b69e-87b6d0c07b2c


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1: TryBot-Result-1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 1: Code-Review+2

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Dmitri Shuralyov:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 2:

Kokoro presubmit build starting for golang/tools/gopls-legacy/presubmit
Logs at:
https://source.cloud.google.com/results/invocations/2f0a1106-b973-48bf-afdc-45e0e579d083


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from kokoro:

Patch Set 2: gopls-CI+1

Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/2f0a1106-b973-48bf-afdc-45e0e579d083


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Tim King:

Patch Set 2: Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 2: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/462596.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Jan 18, 2023
… panic in new parallel subtest check when t.Run has single argument

The new Go 1.20 parallel subtest check in the loopclosure pass
can panic in the rare case of t.Run with a single argument:

    fn := func() (string, func(t *testing.T)) { return "", nil }
    t.Run(fn())

A real-world example:

https://github.com/go-spatial/geom/blob/3cd2f5a9a082dd4f827c9f9b69ba5d736d2dcb12/planar/planar_test.go#L118

This has been present for multiple months without seeming to
be reported, so presumably this is a rare pattern.

Avoid that panic by checking t.Run has an expected number
of arguments.

Fixes golang/go#57908.
Fixes golang/go#57911.

Change-Id: I5cde60edf624e16bb9f534e435bcd55e63a15647
GitHub-Last-Rev: 24e65a4
GitHub-Pull-Request: #424
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462282
Run-TryBot: thepudds <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
Auto-Submit: Russ Cox <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
gopls-CI: kokoro <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462596
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Russ Cox <[email protected]>
Reviewed-by: Tim King <[email protected]>
TryBot-Bypass: Russ Cox <[email protected]>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/462596 has been merged.

@gopherbot gopherbot closed this Jan 18, 2023
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.

cmd/vet: panic in new parallel subtest check when t.Run has single argument
2 participants