Skip to content

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

Closed
@findleyr

Description

@findleyr

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/[email protected]/src/runtime/panic.go:804 +0x154 fp=0x14018b0d8e0 sp=0x14018b0d830 pc=0x10064f724
runtime.panicmem(...)
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:262
runtime.sigpanic()
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/src/runtime/signal_unix.go:917 +0x300 fp=0x14018b0d940 sp=0x14018b0d8e0 pc=0x100651bf0
go/types.(*Package).Path(...)
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/internal/cache/package.go:86 +0x80 fp=0x14018b0dbb0 sp=0x14018b0db20 pc=0x100dbd690
sync.(*Once).doSlow(0x14016f04008?, 0x14016f04580?)
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/src/sync/once.go:76 +0xf8 fp=0x14018b0dc10 sp=0x14018b0dbb0 pc=0x100664eb8
sync.(*Once).Do(...)
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/src/sync/once.go:67
golang.org/x/tools/gopls/internal/cache.(*syntaxPackage).tests(0x14012eb3d40)
	/Users/beingnoble/go/pkg/mod/golang.org/x/tools/[email protected]/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/[email protected]/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/[email protected]/internal/cache/check.go:426 +0x34 fp=0x14018b0dfd0 sp=0x14018b0dfa0 pc=0x100d9e164
runtime.goexit({})
	/Users/beingnoble/go/pkg/mod/golang.org/[email protected]/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/[email protected]/internal/cache/check.go:426 +0x334

I am using gopls v0.17.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions