Skip to content

internal/refactor/inline: "args/params mismatch" panic (reported by telemetry) #64558

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
adonovan opened this issue Dec 5, 2023 · 2 comments
Closed
Assignees
Labels
FrozenDueToAge gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@adonovan
Copy link
Member

adonovan commented Dec 5, 2023

This stack u0ujVg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Errorf:2
golang.org/x/tools/gopls/internal/lsp/source.inlineCall.func2:2
runtime.gopanic:88
golang.org/x/tools/internal/refactor/inline.assert:?2133
golang.org/x/tools/internal/refactor/inline.createBindingDecl:77
golang.org/x/tools/internal/refactor/inline.inline:345
golang.org/x/tools/internal/refactor/inline.Inline:15
golang.org/x/tools/gopls/internal/lsp/source.inlineCall:64
golang.org/x/tools/gopls/internal/lsp/source.ApplyFix:5
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ApplyFix.func1:1
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run.func1:2
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run:72
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ApplyFix:1
golang.org/x/tools/gopls/internal/lsp/command.Dispatch:25
golang.org/x/tools/gopls/internal/lsp.(*Server).executeCommand:19
golang.org/x/tools/gopls@v0.14.2 go1.21.3 darwin/arm64 (1)

createBindingDecl:77 is

	assert(len(values) == 0, "args/params mismatch")

The stack indicates that this refactoring was applied to ill-typed code (hence the recover in source.inlineCall), and the inliner is generally not robust against ill-typed inputs. So potentially this is working as intended, though we should investigate first.

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 5, 2023
@adonovan
Copy link
Member Author

Easily reproduced at master:

xtools$ #go run ./gopls bug  #  fix -a ./a.go:#28 refactor.inline
xtools$ cat a.go
package tools

func f() {
	g(1, 2)
}

func g(x int) {
}

xtools$ go run ./gopls fix -a ./a.go:#28 refactor.inline
Log: Loading packages...
Info: Finished loading packages.
Log: Running...
Info: completed
gopls: inlining failed unexpectedly: args/params mismatch
...huge ugly "stack: [...bytes...]" message redacted...
exit status 2

xtools$ xtools$ go run ./gopls bug
-- 2023-12-11 13:34:42.009829 -0500 EST -- 
/Users/adonovan/w/xtools/gopls/internal/lsp/source/inline.go:101: inlining failed unexpectedly: args/params mismatch
...same huge ugly "stack: [...bytes...]" message redacted
goroutine 1 [running]:
runtime/debug.Stack()
	/Users/adonovan/w/homebrew/Cellar/go/1.21.3/libexec/src/runtime/debug/stack.go:24 +0x64
golang.org/x/tools/gopls/internal/util/bug.report({0x14002ba7800, 0x3547})
	/Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:88 +0xd4
golang.org/x/tools/gopls/internal/util/bug.Errorf({0x104ee7393?, 0xf3d?}, {0x140039dfbc8?, 0x10460f898?, 0x14002785d90?})
	/Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:58 +0x3c
golang.org/x/tools/gopls/internal/lsp/source.inlineCall.func2()
	/Users/adonovan/w/xtools/gopls/internal/lsp/source/inline.go:101 +0x84
panic({0x1051d0480?, 0x1400401f340?})
	/Users/adonovan/w/homebrew/Cellar/go/1.21.3/libexec/src/runtime/panic.go:914 +0x218
golang.org/x/tools/internal/refactor/inline.assert(...)
	/Users/adonovan/w/xtools/internal/refactor/inline/inline.go:2133
golang.org/x/tools/internal/refactor/inline.createBindingDecl(0x1053465b0, 0x14004032240, {0x1400401f290?, 0x2, 0x0?}, 0x14004003920, {0x0, 0x0, 0x1400403e050?})
...

@adonovan adonovan self-assigned this Dec 11, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/548736 mentions this issue: gopls/internal/lsp/source: forgive inliner failures in illtyped code

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants