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/internal/refactor/inline: nil deref in (*freeVisitor).declare #73321

Open
adonovan opened this issue Apr 10, 2025 · 1 comment
Open
Assignees
Labels
BugReport Issues describing a possible bug in the Go implementation. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

@mknyszek encountered this while running our benchmarks.

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

goroutine 2256 [running]:
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7.1()
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:1200 +0x233
panic({0x10ba780?, 0x1d283b0?})
    /home/swarming/.swarming/w/ir/go/src/runtime/panic.go:783 +0x132
golang.org/x/tools/internal/refactor/inline.(*freeVisitor).declare(...)
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/free.go:373
golang.org/x/tools/internal/refactor/inline.(*freeVisitor).shortVarDecl(...)
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/free.go:327
golang.org/x/tools/internal/refactor/inline.(*freeVisitor).Visit(0xc00ad45db8, {0x1553808?, 0xc00ad1b240})
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/free.go:126 +0x20a5
go/ast.Walk({0x1551320?, 0xc00ad45db8?}, {0x1553808, 0xc00ad1b240})
    /home/swarming/.swarming/w/ir/go/src/go/ast/walk.go:34 +0x4c
golang.org/x/tools/internal/refactor/inline.freeishNames(0xc00ad57bc0, {0x1553808, 0xc00ad1b240}, 0x0)
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/free.go:38 +0x79
golang.org/x/tools/internal/refactor/inline.trimNewImports({0x0, 0x0, 0x9?}, {0x1553808, 0xc00ad1b240})
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/inline.go:564 +0x5b
golang.org/x/tools/internal/refactor/inline.(*state).inline(0xc009d95860)
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/inline.go:275 +0x82c
golang.org/x/tools/internal/refactor/inline.Inline(0xc009d0e300, 0xc00a650280, 0xc008a5cf30)
    /home/swarming/.swarming/w/ir/repos/tools/internal/refactor/inline/inline.go:84 +0x96
golang.org/x/tools/internal/gofix.(*analyzer).inlineCall(0xc00ad16340, 0xc00a9f3f40, {0xc0002f3a88?, 0x1164500?})
    /home/swarming/.swarming/w/ir/repos/tools/internal/gofix/gofix.go:273 +0x30d
golang.org/x/tools/internal/gofix.(*analyzer).inline-range1({0xc0002f3a88?, 0x798185?})
    /home/swarming/.swarming/w/ir/repos/tools/internal/gofix/gofix.go:229 +0x167
golang.org/x/tools/internal/astutil/cursor.Cursor.Preorder.func1(0xc00ad090b0)
    /home/swarming/.swarming/w/ir/repos/tools/internal/astutil/cursor/cursor.go:129 +0xaf
golang.org/x/tools/internal/gofix.(*analyzer).inline(0xc00ad16340)
    /home/swarming/.swarming/w/ir/repos/tools/internal/gofix/gofix.go:226 +0xe2
golang.org/x/tools/internal/gofix.run(0xc0096a69a0, 0x1)
    /home/swarming/.swarming/w/ir/repos/tools/internal/gofix/gofix.go:84 +0x127
golang.org/x/tools/internal/gofix.init.func1(0x4792d9?)
    /home/swarming/.swarming/w/ir/repos/tools/internal/gofix/gofix.go:38 +0x18
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7(0x1d49de0, 0xc009d95d48, 0xc0096a69a0, 0xc009d95d10)
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:1213 +0x97
golang.org/x/tools/gopls/internal/cache.(*action).exec(0xc008f70870, {0x15587e0, 0xc008345350})
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:1214 +0xb34
golang.org/x/tools/gopls/internal/cache.execActions.func1.1()
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:908 +0x52
sync.(*Once).doSlow(0x0?, 0xc346c0?)
    /home/swarming/.swarming/w/ir/go/src/sync/once.go:78 +0xab
sync.(*Once).Do(...)
    /home/swarming/.swarming/w/ir/go/src/sync/once.go:69
golang.org/x/tools/gopls/internal/cache.execActions.func1()
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:906 +0x85
created by golang.org/x/tools/gopls/internal/cache.execActions in goroutine 1740
    /home/swarming/.swarming/w/ir/repos/tools/gopls/internal/cache/analysis.go:904 +0x55
2025/04/10 20:03:51 gopls invocation failed with error: exit status 2
exit status 1
FAIL    golang.org/x/tools/gopls/internal/test/integration/bench    1.267s
FAIL
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Apr 10, 2025
@gopherbot gopherbot added this to the Unreleased milestone Apr 10, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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