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

x/tools/gopls: crash in testFuncs with *error argument #70927

Closed
findleyr opened this issue Dec 19, 2024 · 4 comments
Closed

x/tools/gopls: crash in testFuncs with *error argument #70927

findleyr opened this issue Dec 19, 2024 · 4 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Member

findleyr commented Dec 19, 2024

Reported by a user in golang/vscode-go#3617. I can reproduce this with a function that takes *error as its first argument.

(how many times has this caught us out...?)

Here's the panic output:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x100d91b7c]

goroutine 17404 gp=0x14018776700 m=17 mp=0x14016f04008 [running]:
panic({0x101357da0?, 0x101b51f40?})
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/runtime/panic.go:804 +0x154 fp=0x14018b0d8e0 sp=0x14018b0d830 pc=0x10064f724
runtime.panicmem(...)
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/runtime/panic.go:262
runtime.sigpanic()
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/runtime/signal_unix.go:917 +0x300 fp=0x14018b0d940 sp=0x14018b0d8e0 pc=0x100651bf0
go/types.(*Package).Path(...)
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/go/types/package.go:34
golang.org/x/tools/gopls/internal/cache/testfuncs.testKind(0x0?)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/testfuncs/tests.go:284 +0xcc fp=0x14018b0d970 sp=0x14018b0d950 pc=0x100d91b7c
golang.org/x/tools/gopls/internal/cache/testfuncs.isTestOrExample(0x140157c4a80)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/testfuncs/tests.go:254 +0xc8 fp=0x14018b0d9f0 sp=0x14018b0d970 pc=0x100d91908
golang.org/x/tools/gopls/internal/cache/testfuncs.(*indexBuilder).build(0x14018b0db78, {0x1401898a108, 0x3, 0x3}, 0x1401384d8c0)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/testfuncs/tests.go:85 +0x240 fp=0x14018b0db20 sp=0x14018b0d9f0 pc=0x100d90890
golang.org/x/tools/gopls/internal/cache/testfuncs.NewIndex(...)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/testfuncs/tests.go:60
golang.org/x/tools/gopls/internal/cache.(*syntaxPackage).tests.func1()
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/package.go:86 +0x80 fp=0x14018b0dbb0 sp=0x14018b0db20 pc=0x100dbd690
sync.(*Once).doSlow(0x14016f04008?, 0x14016f04580?)
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/sync/once.go:76 +0xf8 fp=0x14018b0dc10 sp=0x14018b0dbb0 pc=0x100664eb8
sync.(*Once).Do(...)
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/sync/once.go:67
golang.org/x/tools/gopls/internal/cache.(*syntaxPackage).tests(0x14012eb3d40)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/package.go:85 +0x4c fp=0x14018b0dc40 sp=0x14018b0dc10 pc=0x100dbd5dc
golang.org/x/tools/gopls/internal/cache.storePackageResults({0x101497ea8, 0x140160c7350}, 0x140120970e0, 0x1401b593c20)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/check.go:438 +0x1b4 fp=0x14018b0dfa0 sp=0x14018b0dc40 pc=0x100d9e514
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getPackage.func1.gowrap1()
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/check.go:426 +0x34 fp=0x14018b0dfd0 sp=0x14018b0dfa0 pc=0x100d9e164
runtime.goexit({})
	/Users/beingnoble/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.darwin-arm64/src/runtime/asm_arm64.s:1223 +0x4 fp=0x14018b0dfd0 sp=0x14018b0dfd0 pc=0x1006588f4
created by golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getPackage.func1 in goroutine 14636
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/gopls@v0.17.0/internal/cache/check.go:426 +0x334

I am using gopls v0.17.0

Originally posted by @beingnoble03 in golang/vscode-go#3617 (comment)

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 19, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 19, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.17.1 Dec 19, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637815 mentions this issue: gopls/internal/cache/testfuncs: fix crash with *error argument

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/637736 mentions this issue: [gopls-release-branch.0.17] gopls/internal/cache/testfuncs: fix crash with *error argument

gopherbot pushed a commit to golang/tools that referenced this issue Dec 19, 2024
… with *error argument

The test detection logic incorrectly assumes that named types have a
non-nil package, which is not true for Error (as we've encountered
numerous times). Add the missing nil check.

Fixes golang/go#70927

Change-Id: Ibdf483304b53ce219123e820d74acd4f9d12d710
Reviewed-on: https://go-review.googlesource.com/c/tools/+/637815
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit dcc725c)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/637736
@beingnoble03
Copy link

Thanks for the fix @findleyr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants