Skip to content

x/tools/gopls: "internal error converting diagnostic" (bug reported by telemetry) #64547

Closed
@adonovan

Description

@adonovan
#!stacks
"bug.Reportf" && ("cache.(*action).exec.func3:+4") 

This stack o6rQWQ was reported by telemetry:

cache.(*action).exec.func3:3 is :

		Report: func(d analysis.Diagnostic) {
			diagnostic, err := toGobDiagnostic(posToLocation, analyzer, d)
			if err != nil {
				bug.Reportf("internal error converting diagnostic from analyzer %q: %v", analyzer.Name, err)
				return
			}
			diagnostics = append(diagnostics, diagnostic)
		},

Variant stacks from cgocall analyzer: t5Iynw, anAjSQ, WNmwJA, lkeNLw, 1ZKXaA, iv8Nzg, 99HJig, o9Ch_g.

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.(*action).exec.func3:3
golang.org/x/tools/go/analysis.(*Pass).ReportRangef:2
golang.org/x/tools/go/analysis/passes/lostcancel.runFunc:108
golang.org/x/tools/go/analysis/passes/lostcancel.run.func1:1
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder:11
golang.org/x/tools/go/analysis/passes/lostcancel.run:12
golang.org/x/tools/gopls/internal/lsp/cache.(*action).exec.func6:31
golang.org/x/tools/gopls/internal/lsp/cache.(*action).exec:177
golang.org/x/tools/gopls/internal/lsp/cache.execActions.func1.1:2
sync.(*Once).doSlow:5
sync.(*Once).Do:?65
golang.org/x/tools/gopls/internal/lsp/cache.execActions.func1:2
runtime.goexit:0
golang.org/x/tools/gopls@v0.14.2 go1.21.3 darwin/amd64 (1)

Errors from toGobDiagnostic must come from posToLocation, which can fail if a token.Pos from the analyzer (in this case, a valid ReturnStmt in lostcancel) either doesn't belong to the FileSet or is invalid per safetoken.Offset. I suspect this is another case of AST fixing making offsets invalid.

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

Dups:

This stack 6NklUg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.(*action).exec.func3:3
golang.org/x/tools/go/analysis.(*Pass).Reportf:2
golang.org/x/tools/go/analysis/passes/cgocall.checkCgo.func1:28
go/ast.inspector.Visit:1
go/ast.Walk:1
go/ast.walkExprList:?26
go/ast.Walk:167
go/ast.Walk:188
go/ast.walkStmtList:?32
go/ast.Walk:184
go/ast.Walk:307
go/ast.walkDeclList:?38
go/ast.Walk:316
go/ast.Inspect:?397
golang.org/x/tools/gopls@v0.14.2 go1.21.1 darwin/arm64 vscode (4)

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

This stack pDy33Q 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/cache.(*action).exec.func2:11
golang.org/x/tools/gopls/internal/lsp/cache.toGobDiagnostic:32
golang.org/x/tools/gopls/internal/lsp/cache.(*action).exec.func3:1
golang.org/x/tools/go/analysis.(*Pass).Reportf:2
golang.org/x/tools/go/analysis/passes/cgocall.checkCgo.func1:28
go/ast.inspector.Visit:1
go/ast.Walk:1
go/ast.walkExprList:?26
go/ast.Walk:167
go/ast.Walk:188
go/ast.walkStmtList:?32
go/ast.Walk:184
go/ast.Walk:307
go/ast.walkDeclList:?38
golang.org/x/tools/gopls@v0.14.2 go1.21.1 darwin/arm64 vscode (4)

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

This stack WQ0V3g was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+4
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run.func1:+25
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder:+11
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run:+7
golang.org/x/tools/gopls/internal/cache.(*action).exec.func6:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+193
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=65
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.1 go1.21.3 linux/amd64 vscode (1)

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

This stack HGXlMQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+4
honnef.co/go/tools/analysis/report.Report:+25
honnef.co/go/tools/staticcheck.CheckTypedNilInterface:+100
golang.org/x/tools/gopls/internal/cache.(*action).exec.func6:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+193
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=65
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.1 go1.22.0 darwin/arm64 other,vscode-insiders (3)

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

This stack Kf5dlg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+4
honnef.co/go/tools/analysis/report.Report:+25
honnef.co/go/tools/staticcheck.CheckTypedNilInterface:+100
golang.org/x/tools/gopls/internal/cache.(*action).exec.func6:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+215
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=65
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.3 go1.22.2 darwin/arm64 other,vscode-insiders (1)

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

Dup: qaVg3w Eqzixw HRixng g_9bVA 3BjAWg 5rID1Q J_xyOQ nkqhZw DD7DZw KXNLJA aabnaw xEGAsg V5I6ag AjGTng y5Uv9w nJQxXw uxzQyw Kf5dlg W-MgtA HkRVLw -Zs1-Q m1uRmQ
Dups: KW9hqg

Activity

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
goplsIssues related to the Go language server, gopls.
ToolsThis label describes issues relating to any tools in the x/tools repository.
on Dec 5, 2023
added this to the Unreleased milestone on Dec 5, 2023
adonovan

adonovan commented on Dec 26, 2023

@adonovan
MemberAuthor

All these stacks appear to come from the cgocall analyzer. I suspect it is special because of cgo's use of //line directives, which cause the apparent file offsets not to match the actual file size.

self-assigned this
on Jan 18, 2024
gopherbot

gopherbot commented on Jan 18, 2024

@gopherbot
Contributor

Change https://go.dev/cl/556815 mentions this issue: gopls/internal/lsp/cache: fix bug reports from toGobDiagnostics

adonovan

adonovan commented on Mar 7, 2024

@adonovan
MemberAuthor

Reopening due to field report in v0.15.1, after the supposed fix in CL https://go.dev/cl/556815:

This stack WQ0V3g was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.(*action).exec.func3:+4
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run.func1:+25
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder:+11
golang.org/x/tools/gopls/internal/analysis/noresultvalues.run:+7
golang.org/x/tools/gopls/internal/cache.(*action).exec.func6:+31
golang.org/x/tools/gopls/internal/cache.(*action).exec:+193
golang.org/x/tools/gopls/internal/cache.execActions.func1.1:+2
sync.(*Once).doSlow:+5
sync.(*Once).Do:=65
golang.org/x/tools/gopls/internal/cache.execActions.func1:+2
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.1 go1.21.3 linux/amd64 vscode (1)

56 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/telemetry-wins

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @hyangah@adonovan@gopherbot@findleyr

      Issue actions

        x/tools/gopls: "internal error converting diagnostic" (bug reported by telemetry) · Issue #64547 · golang/go