-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: panic in token.File.Name within PackageDocHTML (telemetry) #70149
Comments
@adonovan Hello! I guess I found a bug. May I contribute a fix? After that I have the same stacktrace in my neovim log:
I guess the fix might be here: /src/go/ast/ast.go#L1057 (or in tools code near the caller logic) There is no package in the file so the documentation might not be generated. |
Thanks for explaining the input that caused the crash! There are actually two bugs here. The first is that the loop in PackageDocHTML should not assume that File.Pos() is valid, as it may not be for (e.g.) empty files; instead it should use File.FileStart. However, the second bug is that the parser fails to populate FileStart and FileEnd in the case of an empty file; I've filed that separately as #70162. |
Change https://go.dev/cl/624437 mentions this issue: |
Issue created by stacks.
This stack
BQeQrg
was reported by telemetry:gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Report:+1
golang.org/x/tools/gopls/internal/server.(*server).initWeb.withPanicHandler.func10.1:+2
runtime.gopanic:+50
runtime.panicmem:=262
runtime.sigpanic:+19
go/token.(*File).Name:=114
golang.org/x/tools/gopls/internal/golang.PackageDocHTML:+12
golang.org/x/tools/gopls/internal/server.(*server).initWeb.func6:+40
net/http.HandlerFunc.ServeHTTP:+1
golang.org/x/tools/gopls/internal/server.(*server).initWeb.StripPrefix.func11:+10
net/http.HandlerFunc.ServeHTTP:+1
net/http.(*ServeMux).ServeHTTP:+14
golang.org/x/tools/gopls/internal/server.(*server).initWeb.StripPrefix.func9:+10
net/http.HandlerFunc.ServeHTTP:+1
golang.org/x/tools/gopls/internal/server.(*server).initWeb.withPanicHandler.func10:+7
The text was updated successfully, but these errors were encountered: