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

go/types, types2: gopls crash in computeInterfaceTypeSet with "duplicate method" #51316

Closed
wushilin opened this issue Feb 20, 2022 · 4 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@wushilin
Copy link

gopls version: v0.8.0-pre.2
gopls flags:
update flags: proxy
extension version: 2022.2.1423
go version: 1.18beta2
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Sun, 20 Feb 2022 01:22:52 GMT
restart history:
Sun, 20 Feb 2022 00:43:53 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: 2229938: duplicate method Contains

goroutine 995 [running]:
go/types.(*Checker).handleBailout(0xc002f50000, 0xc00179d650)
	  check.go:304  0x8b
panic({0x186bf00, 0xc001e97990})
	  panic.go:838  0x207
go/types.computeInterfaceTypeSet.func2(0x2206b2, 0xc002622280, 0x1)
	  typeset.go:233  0x5bd
go/types.computeInterfaceTypeSet(0x0, 0x18cbec0%3F, 0xc0020170e0)
	  typeset.go:260  0x2d5
go/types.(*Interface).typeSet(...)
	  interface.go:29
go/types.(*Interface).Empty(0x1bf2dc0%3F)
	  interface.go:111  0x25
go/types.(*Checker).implements(0xc002f50000, {0x1bf2de8%3F, 0xc001e97590}, {0x1bf2dc0%3F, 0xc000543730})
	  instantiate.go:187  0x485
go/types.(*operand).assignableTo(0xc002a98600, 0xc002f50000, {0x1bf2dc0%3F, 0xc000543730%3F}, 0xc00179bbf0)
	  operand.go:283  0x9c5
go/types.(*Checker).assignment(0xc002f50000, 0xc002a98600, {0x1bf2dc0, 0xc000543730}, {0xc0010e0e70, 0x18})
	  assignments.go:87  0x80b
go/types.(*Checker).arguments(0xc002f50000, 0xc001f05dc0, 0xc002a985c0, {0x0, 0x0, 0x0}, {0xc001f864a0%3F, 0x1, 0x1}, {0x0, ...})
	  call.go:414  0xbf4
go/types.(*Checker).callExpr(0xc002f50000, 0xc002a98500, 0xc001f05dc0)
	  call.go:210  0x669
go/types.(*Checker).exprInternal(0xc002f50000, 0xc002a98500, {0x1bf4e30%3F, 0xc001f05dc0}, {0x0%3F, 0x0%3F})
	  expr.go:1483  0x9f2
go/types.(*Checker).rawExpr(0xc002f50000%3F, 0x1bf0f20%3F, {0x1bf4e30%3F, 0xc001f05dc0%3F}, {0x0%3F, 0x0%3F}, 0x0)
	  expr.go:1111  0x45
go/types.(*Checker).stmt(0xc002f50000, 0x0, {0x1bf4fe0%3F, 0xc00229dec0%3F})
	  stmt.go:394  0x247c
go/types.(*Checker).stmtList(0xc002f50000%3F, 0x0, {0xc0007e6400%3F, 0x0%3F, 0xc0007f8800%3F})
	  stmt.go:125  0xc9
go/types.(*Checker).funcBody(0xc002f50000, 0xc002f33b00, {0x1bf2d70%3F, 0xc001762b88%3F}, 0xc002066b80, 0xc0021022a0, {0x0, 0x0})
	  stmt.go:46  0x285
go/types.(*Checker).funcDecl.func1()
	  decl.go:790  0x45
go/types.(*Checker).processDelayed(0xc002f50000, 0x0)
	  check.go:375  0x39
go/types.(*Checker).checkFiles(0xc002f50000, {0xc0016386e0%3F, 0xc002f08f00%3F, 0x0%3F})
	  check.go:326  0xcb
go/types.(*Checker).Files(...)
	  check.go:309
golang.org/x/tools/internal/lsp/cache.doTypeCheck({0x1bf64e0, 0xc001f05300}, 0xc00036b560, 0xc00081de00, 0x2, 0xc001014ae0, 0x19a8093%3F)
	  check.go:548  0x97b
golang.org/x/tools/internal/lsp/cache.typeCheck({0x1bf64e0, 0xc001f05300}, 0xc00036b560, 0xc00081de00, 0x2, 0xc001014ae0%3F)
	  check.go:314  0xe5
golang.org/x/tools/internal/lsp/cache.(*snapshot).buildPackageHandle.func1({0x1bf64e0%3F, 0xc001f05300}, {0x1befd00%3F, 0xc00036b560})
	  check.go:125  0x233
golang.org/x/tools/internal/memoize.(*Handle).run.func1()
	  memoize.go:327  0xa9
created by golang.org/x/tools/internal/memoize.(*Handle).run
	  memoize.go:320  0x1b8
[Error - 9:22:28 AM] 

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 findleyr changed the title gopls: automated issue report (crash) go/types, types2: gopls crash in computeInterfaceTypeSet with "duplicate method" Feb 22, 2022
@findleyr findleyr transferred this issue from golang/vscode-go Feb 22, 2022
@findleyr findleyr added this to the Go1.18 milestone Feb 22, 2022
@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 22, 2022
@findleyr
Copy link
Contributor

CC @griesemer

@griesemer
Copy link
Contributor

It appears that the Interface.check field is nil when we still need it for type set computation. There's the following places where we create an Interface w/o setting its check field during type checking:

  • builtins.go calls NewInterface which doesn't set the check field (this happens only for real, imag and complex built-ins)
  • named.go and subst.go allocate new interfaces through &Interface{...} without setting the check field

These seem wrong.

There may be places where we clear the check field but shouldn't, or where we throw away the type set (tset field set to nil) but don't have a Checker anymore but need one when the type set is recomputed.

@griesemer griesemer self-assigned this Feb 22, 2022
@griesemer
Copy link
Contributor

@wushilin Is there any possibility that you could send us a snippet of source code (not your analyzer or whatever tool is using go/types, but the code on which the tool is crashing)? That would be helpful for reproduction.

@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 22, 2022
@gopherbot
Copy link

Change https://go.dev/cl/387417 mentions this issue: types2: generalize cleanup phase after type checking

@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants