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 exporting constant with partially defined type #60891

Closed
VitorBaldacin opened this issue Jun 19, 2023 · 3 comments
Closed
Assignees
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

@VitorBaldacin
Copy link

gopls version: v0.12.2 (go1.20)
gopls flags:
update flags: proxy
extension version: 0.39.0
go version: 1.20
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Mon, 19 Jun 2023 20:49:05 GMT
restart history:
Mon, 19 Jun 2023 20:48:37 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x729994]

goroutine 10475 [running]:
golang.org/x/tools/internal/gcimporter.iexportCommon.func1()
	  iexport.go:93  0x8a
panic({0xdc2b00, 0x16b8180})
	  panic.go:884  0x213
go/types.(*Package).Path(...)
	  package.go:31
golang.org/x/tools/internal/gcimporter.(*exportWriter).exportPath(...)
	  iexport.go:426
golang.org/x/tools/internal/gcimporter.(*exportWriter).pkg(0xc00591aa80, 0x0)
	  iexport.go:664  0x54
golang.org/x/tools/internal/gcimporter.(*exportWriter).setPkg(...)
	  iexport.go:832
golang.org/x/tools/internal/gcimporter.(*exportWriter).doTyp(0xc00591aa80, {0x1149df8%3F, 0xc007a22630%3F}, 0x0)
	  iexport.go:776  0x514
golang.org/x/tools/internal/gcimporter.(*iexporter).typOff(0xc0062be0f0, {0x1149df8, 0xc007a22630}, 0x0%3F)
	  iexport.go:694  0x92
golang.org/x/tools/internal/gcimporter.(*exportWriter).typ(0xc00591aa20, {0x1149df8%3F, 0xc007a22630%3F}, 0x7293f7%3F)
	  iexport.go:677  0x2e
golang.org/x/tools/internal/gcimporter.(*exportWriter).typeList(0xc00591aa20, 0xc0049c7b60, 0x0%3F)
	  iexport.go:849  0x7b
golang.org/x/tools/internal/gcimporter.(*exportWriter).doTyp(0xc00591aa20, {0x1149d58%3F, 0xc0066039d0%3F}, 0x0)
	  iexport.go:721  0xf3
golang.org/x/tools/internal/gcimporter.(*iexporter).typOff(0xc0062be0f0, {0x1149d58, 0xc0066039d0}, 0x264dfd%3F)
	  iexport.go:694  0x92
golang.org/x/tools/internal/gcimporter.(*exportWriter).typ(0xc00591a9c0, {0x1149d58%3F, 0xc0066039d0%3F}, 0xc0034fd560%3F)
	  iexport.go:677  0x2e
golang.org/x/tools/internal/gcimporter.(*exportWriter).value(0xc00591a9c0, {0x1149d58%3F, 0xc0066039d0}, {0x114d9f0, 0xc007a228a0})
	  iexport.go:911  0x45
golang.org/x/tools/internal/gcimporter.(*iexporter).doDecl(0xc0062be0f0, {0x1156518, 0xc004650ba0})
	  iexport.go:481  0x2ed
golang.org/x/tools/internal/gcimporter.iexportCommon({0x1145de0, 0xc007fdf2f0}, 0xc0041d39c0, 0x0, 0x1, 0x2, {0xc006afdca8, 0x1, 0xc007fdf260%3F})
	  iexport.go:139  0x3a5
golang.org/x/tools/internal/gcimporter.IExportShallow(0xdbcfe0%3F, 0xc00451a780)
	  iexport.go:43  0x75
golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
	  check.go:646  0x2b1
created by golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage
	  check.go:638  0x305
[Error - 17:48:56] 

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@findleyr
Copy link
Contributor

Hi, thank you for the report. I will look at the call stack to see if I can figure it out, but do you have any idea what you were typing when you encountered the crash?

@findleyr
Copy link
Contributor

findleyr commented Jun 20, 2023

Nevermind, I can reproduce!

package main

type I[P any] int

const C I[struct{}] = 42

Thanks again. Fix incoming.

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: crash exporting constant with partially defined type Jun 20, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Jun 20, 2023
@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 Jun 20, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 20, 2023
@findleyr findleyr self-assigned this Jun 20, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.12.3 Jun 20, 2023
@gopherbot
Copy link

Change https://go.dev/cl/504556 mentions this issue: internal/gcimporter: avoid a crash when exporting a struct with no pkg

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

3 participants