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: nil panic loading analysisNode.summary #66732

Open
jstbyte opened this issue Apr 7, 2024 · 6 comments
Open

x/tools/gopls: nil panic loading analysisNode.summary #66732

jstbyte opened this issue Apr 7, 2024 · 6 comments
Assignees
Labels
gopls/analysis Issues related to running analysis in gopls gopls/telemetry-wins 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

@jstbyte
Copy link

jstbyte commented Apr 7, 2024

gopls version: v0.15.2/go1.20.1
gopls flags:
update flags: proxy
extension version: 0.41.2
environment: Visual Studio Code win32
initialization error: undefined
issue timestamp: Sun, 07 Apr 2024 03:13:55 GMT
restart history:
Sun, 07 Apr 2024 03:01:06 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x40 pc=0x163a7fc]

goroutine 186 [running]:
golang.org/x/tools/gopls/internal/cache.(*Snapshot).Analyze(0x0, {0x1e17ad8, 0xc00082df50}, 0xc000219bf0, {0xc00017f800, 0xcc, 0xc000867d88%3F}, 0xc00048ea20)
	  analysis.go:461  0x139c
golang.org/x/tools/gopls/internal/golang.Analyze({0x1e17ad8, 0xc00082df50}, 0xc00007e240, 0xc0005a5560%3F, 0x1a4f8a0%3F)
	  diagnostics.go:42  0x16b
golang.org/x/tools/gopls/internal/server.(*server).diagnose.func6()
	  diagnostics.go:507  0xc5
created by golang.org/x/tools/gopls/internal/server.(*server).diagnose
	  diagnostics.go:502  0x10a5
gopls stats -anon { "DirStats": { "Files": 2, "TestdataFiles": 0, "GoFiles": 1, "ModFiles": 1, "Dirs": 1 }, "GOARCH": "amd64", "GOOS": "windows", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.20.1", "GoplsVersion": "v0.15.2", "InitialWorkspaceLoadDuration": "1.8348831s", "MemStats": { "HeapAlloc": 2531088, "HeapInUse": 5169152, "TotalAlloc": 12289392 }, "WorkspaceStats": { "Files": { "Total": 2, "Largest": 60, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.2", "AllPackages": { "Packages": 1, "LargestPackage": 1, "CompiledGoFiles": 1, "Modules": 1 }, "WorkspacePackages": { "Packages": 1, "LargestPackage": 1, "CompiledGoFiles": 1, "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.

<OPTIONAL: ATTACH LOGS HERE>

Dups: 3DjTOg

@findleyr
Copy link
Contributor

findleyr commented Apr 8, 2024

CC @adonovan: another mysterious case where analysisNode.summary may be nil.

@adonovan
Copy link
Member

adonovan commented Apr 8, 2024

It's definitely the summary and not the root that is nil.

xtools$ git co  gopls/v0.15.2
xtools$ GOOS=windows GOARCH=amd64 GOTOOLCHAIN=go1.20.1 go build -o x ./gopls
xtools$ go tool objdump -S x | less
...
  0xa7a81c              48898c2470010000        MOVQ CX, 0x170(SP)      
                        srcAnalyzer, ok := toSrc[a]
  0xa7a824              488d05155a4000          LEAQ type:*+799296(SB), AX              
  0xa7a82b              488d9c2448030000        LEAQ 0x348(SP), BX                      
  0xa7a833              e8487f99ff              CALL runtime.mapaccess2_fast64(SB)      
  0xa7a838              488b10                  MOVQ 0(AX), DX                          
  0xa7a83b              0f1f440000              NOPL 0(AX)(AX*1)                        
  0xa7a840              84db                    TESTL BL, BL                            
                        if !ok {
  0xa7a842              0f84b0000000            JE 0xa7a8f8             
                        srcAnalyzer, ok := toSrc[a]
  0xa7a848              48899424f8000000        MOVQ DX, 0xf8(SP) // spill srcAnalyzer     
                        summary, ok := root.summary.Actions[stableNames[a]]
  0xa7a850              488b942408010000        MOVQ 0x108(SP), DX                      
  0xa7a858              488b7278                MOVQ 0x78(DX), SI  // load root.summary             
  0xa7a85c              488b7640                MOVQ 0x40(SI), SI // load analyzeSummary.Actions <-- SEGV here
  0xa7a860              4889b42498010000        MOVQ SI, 0x198(SP)                      
  0xa7a868              488b8c2470010000        MOVQ 0x170(SP), CX                      
  0xa7a870              488d05e95a4000          LEAQ type:*+799584(SB), AX     // type for stableNames map             
  0xa7a877              488b9c24f0000000        MOVQ 0xf0(SP), BX                       
  0xa7a87f              90                      NOPL                                    
  0xa7a880              e85b7d99ff              CALL runtime.mapaccess1_fast64(SB)      

(Lovin' the new hover size/offset feature!)

@adonovan adonovan changed the title gopls: automated issue report (crash) gopls: nil panic loading analysisNode.summary Apr 8, 2024
@adonovan adonovan self-assigned this Apr 8, 2024
@adonovan adonovan added the gopls/analysis Issues related to running analysis in gopls label Apr 8, 2024
@adonovan adonovan transferred this issue from golang/vscode-go Apr 8, 2024
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Apr 8, 2024
@adonovan adonovan changed the title gopls: nil panic loading analysisNode.summary x/tools/gopls: nil panic loading analysisNode.summary Apr 8, 2024
@adonovan adonovan added this to the gopls/v0.16.0 milestone Apr 8, 2024
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Apr 8, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577435 mentions this issue: gopls/internal/cache: add debug assertions to refine golang/go#66732

gopherbot pushed a commit to golang/tools that referenced this issue Apr 8, 2024
Also, use go1.19 generic helpers for atomics.

Updates golang/go#66732

Change-Id: I7aa447144353ff2ac5906ca746e2f98b115aa732
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577596 mentions this issue: [gopls-release-branch.0.15] gopls/internal/cache: add debug assertions to refine golang/go#66732

gopherbot pushed a commit to golang/tools that referenced this issue Apr 9, 2024
…s to refine golang/go#66732

Also, use go1.19 generic helpers for atomics.

Updates golang/go#66732
Updates golang/go#66730

Change-Id: I7aa447144353ff2ac5906ca746e2f98b115aa732
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
(cherry picked from commit f6298eb)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577596
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Apr 16, 2024
https://build.opensuse.org/request/show/1167900
by user jfkw + anag+factory
- Update to version 0.15.3:
  * gopls: update go.mod for v0.15.3-pre.2
  * gopls/internal/server: don't reset views if configuration did not change
  * gopls: update go.mod for v0.15.3-pre.1
  * gopls/internal/cache: add debug assertions to refine golang/go#66732
  * gopls/internal/cache: analysis: repair start/end and refine bug report
  * gopls/internal/cache: avoid panic when the primary diagnostic is broken
  * internal/check: filter out too-new Go versions for type checking
  * gopls/internal/cache: fix crash in snapshot.Analyze with patch versions
  * gopls/internal/server: filter diagnostics to "best" views
  * internal/imports: fix two "nil pointer in interface" bugs
  * all: add replace directive to help stage the v0.15.3 release
  * gopls: fix test failures due to quoting of names
@findleyr findleyr modified the milestones: gopls/v0.16.0, gopls/v0.17.0 May 23, 2024
@adonovan
Copy link
Member

adonovan commented Sep 3, 2024

This stack 3DjTOg was reported by telemetry:

"root analysisNode has nil summary"

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Report:=68
golang.org/x/tools/gopls/internal/cache.(*Snapshot).Analyze:+263
golang.org/x/tools/gopls/internal/golang.Analyze:+12
golang.org/x/tools/gopls/internal/server.(*server).diagnose.func6:+5
runtime.goexit:+0
golang.org/x/tools/gopls@v0.16.2-pre.1 go1.22.2 linux/amd64 other,vscode-insiders (1)

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

@findleyr
Copy link
Contributor

This may still be a problem but I'm bumping to v0.18.0 as the analysis driver has changed significantly; let's reevaluate after v0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/analysis Issues related to running analysis in gopls gopls/telemetry-wins 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

4 participants