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 in mapPosition computing OutgoingCalls to unsafe.Slice #66923

Open
ceearrashee opened this issue Apr 18, 2024 · 3 comments
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

@ceearrashee
Copy link

ceearrashee commented Apr 18, 2024

gopls version: v0.15.3/go1.22.2
gopls flags:
update flags: proxy
extension version: 0.41.2
environment: Visual Studio Code win32
initialization error: undefined
issue timestamp: Thu, 18 Apr 2024 19:20:56 GMT
restart history:
Thu, 18 Apr 2024 18:12:44 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Please attach the stack trace from the crash.
A window with the error message should have popped up in the lower half of your screen.
Please copy the stack trace and error messages from that window and paste it in this issue.

Failed to auto-collect gopls trace: no gopls log.

gopls stats -anon { "DirStats": { "Files": 5496, "TestdataFiles": 0, "GoFiles": 413, "ModFiles": 1, "Dirs": 383 }, "GOARCH": "amd64", "GOOS": "windows", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.2", "GoplsVersion": "v0.15.3", "InitialWorkspaceLoadDuration": "5.9188475s", "MemStats": { "HeapAlloc": 135173400, "HeapInUse": 197967872, "TotalAlloc": 1481395568 }, "WorkspaceStats": { "Files": { "Total": 4366, "Largest": 6161825, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.2", "AllPackages": { "Packages": 876, "LargestPackage": 279, "CompiledGoFiles": 4437, "Modules": 157 }, "WorkspacePackages": { "Packages": 108, "LargestPackage": 61, "CompiledGoFiles": 487, "Modules": 1 }, "Diagnostics": 0 } ] } }

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.

[Error - 22:20:56] Request textDocument/typeDefinition failed.
  Message: no type definition for SetCap
  Code: 0 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x169d61c]

goroutine 124273 [running]:
go/token.(*File).Name(...)
	C:/Program Files/Go/src/go/token/position.go:109
golang.org/x/tools/gopls/internal/golang.mapPosition({0x1da8368, 0xc01db76090}, 0x0?, {0x1da0060, 0xc00c826000}, 0x0, 0x7)
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/golang/definition.go:301 +0x5c
golang.org/x/tools/gopls/internal/golang.OutgoingCalls({0x1da8368?, 0xc01b477290?}, 0xc00c826000, {0x1daad80, 0xc0082e2ea0}, {0x132?, 0x0?})
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/golang/call_hierarchy.go:282 +0xb32
golang.org/x/tools/gopls/internal/server.(*server).OutgoingCalls(0xc0002c4000, {0x1da83a0?, 0xc021d9b3b0?}, 0xc032136460)
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/server/call_hierarchy.go:58 +0x195
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x1da83a0, 0xc021d9b3b0}, {0x1dc3120, 0xc0002c4000}, 0xc01b4771d0, {0x1da8560, 0xc00b8da680})
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/protocol/tsserver.go:131 +0x4daa
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3({0x1da83a0, 0xc021d9b3b0}, 0xc01b4771d0, {0x1da8560, 0xc00b8da680})
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/protocol/protocol.go:160 +0x85
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x1da83a0, 0xc021d9b3b0}, 0xc01b4771d0, {0x1da8560, 0xc00b8da680})
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/lsprpc/lsprpc.go:509 +0x923
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x1da83a0, 0xc021d9b3b0}, 0xc0190a6528, {0x1da8560, 0xc00b8da680})
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217/internal/jsonrpc2/handler.go:35 +0xc6
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2()
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217/internal/jsonrpc2/handler.go:103 +0x96
created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 124
	C:/Users/eandr/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217/internal/jsonrpc2/handler.go:100 +0x1c5
[Error - 22:20:56] 

@hyangah
Copy link
Contributor

hyangah commented Apr 19, 2024

@ceearrashee Thanks for the report. It looks like browsing outgoing call hierarchy triggered the panic. Can you tell us more about when you observed this crash?

  • Were you checking the function or method named SetCap?
  • Did you notice other errors or problems before this crash? (code navigation not functioning, squiggles indicating problems in the code, etc)

@adonovan @findleyr Is this a known issue?

@findleyr
Copy link
Contributor

@hyangah no this is not a known issue, though I don't think this code has changed in a long time.

@ceearrashee is this reproducible?

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: crash mapping positions in OutgoingCalls Apr 19, 2024
@findleyr findleyr transferred this issue from golang/vscode-go Apr 19, 2024
@findleyr findleyr added this to the gopls/v0.16.0 milestone Apr 19, 2024
@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 Apr 19, 2024
@adonovan
Copy link
Member

adonovan commented Apr 19, 2024

I can reproduce this by computing a call hierarchy involving a call to unsafe.Slice.

These special functions cause no end of bugs.

@adonovan adonovan changed the title x/tools/gopls: crash mapping positions in OutgoingCalls x/tools/gopls: crash in mapPosition computing OutgoingCalls to unsafe.Slice Apr 19, 2024
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

5 participants