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

gopls: automated issue report (crash) #3534

Closed
aronchick opened this issue Sep 11, 2024 · 1 comment
Closed

gopls: automated issue report (crash) #3534

aronchick opened this issue Sep 11, 2024 · 1 comment
Milestone

Comments

@aronchick
Copy link

gopls version: v0.16.2/go1.22.6
gopls flags:
update flags: proxy
extension version: 0.42.0
environment: Cursor darwin
initialization error: undefined
issue timestamp: Wed, 11 Sep 2024 17:58:43 GMT
restart history:
Tue, 10 Sep 2024 16:14:34 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 SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104d258c0]

goroutine 47212 [running]:
golang.org/x/tools/gopls/internal/cache.(*analysisNode).typeCheck(0x1400f8ebba0, {0x140097618c0, 0xb, 0xb})
	  analysis.go:1088  0x890
golang.org/x/tools/gopls/internal/cache.(*analysisNode).run(0x1400f8ebba0, {0x1053be4a8, 0x14012a88720})
	  analysis.go:835  0x174
golang.org/x/tools/gopls/internal/cache.(*analysisNode).runCached(0x1400f8ebba0, {0x1053be4a8, 0x14012a88720})
	  analysis.go:694  0x100
golang.org/x/tools/gopls/internal/cache.(*Snapshot).Analyze.func6.1()
	  analysis.go:402  0xa4
golang.org/x/sync/errgroup.(*Group).Go.func1()
	  errgroup.go:78  0x58
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 46856
	  errgroup.go:75  0x98
gopls stats -anon { "DirStats": { "Files": 100255, "TestdataFiles": 7, "GoFiles": 5012, "ModFiles": 4, "Dirs": 13214 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.6", "GoplsVersion": "v0.16.2", "InitialWorkspaceLoadDuration": "2.385167916s", "MemStats": { "HeapAlloc": 136284960, "HeapInUse": 192028672, "TotalAlloc": 2049657912 }, "WorkspaceStats": { "Files": { "Total": 5341, "Largest": 13374010, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.6", "AllPackages": { "Packages": 1029, "LargestPackage": 636, "CompiledGoFiles": 5456, "Modules": 164 }, "WorkspacePackages": { "Packages": 40, "LargestPackage": 16, "CompiledGoFiles": 210, "Modules": 1 }, "Diagnostics": 109 } ] } }

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>

@gopherbot gopherbot added this to the Untriaged milestone Sep 11, 2024
@adonovan
Copy link
Member

adonovan commented Sep 12, 2024

The offending line of code is:

func (an *analysisNode) typeCheck(parsed []*parsego.File) *analysisPackage {
     ...
	for _, path := range paths {
		dep, ok := an.allDeps[path]
		if !ok {
			log.Fatalf("%s: missing dependency: %q", an, path)
		}
		fmt.Fprintf(hash, "%s %s\n", dep.mp.PkgPath, dep.summary.DeepExportHash) // <--- SIGSEGV
		an.exportDeps[path] = dep
	}

There are several possible dereference operations on that line. Building the executable with GOTOOLCHAIN=go1.22.6 GOOS=darwin GOARCH=arm64 shows that it is the summary field that is nil:
...

  analysis.go:1088      0x1007998a4             97e1d18b                CALL runtime.convTstring(SB)                                                    
  analysis.go:1088      0x1007998a8             90002882                ADRP 5308416(PC), R2                                                            
  analysis.go:1088      0x1007998ac             91020042                ADD $128, R2, R2                                                                
  analysis.go:1088      0x1007998b0             f9005fe2                MOVD R2, 184(RSP)                                                               
  analysis.go:1088      0x1007998b4             f90063e0                MOVD R0, 192(RSP)                                                               
  analysis.go:1088      0x1007998b8             f94053e3                MOVD 160(RSP), R3     // load spilled dep                                                          
  analysis.go:1088      0x1007998bc             f9404864                MOVD 144(R3), R4       // load dep.summary                                                       
  analysis.go:1088      0x1007998c0             3980009b                MOVB (R4), R27          // load dep.summary.Export??: SIGSEGV                                                         
  analysis.go:1088      0x1007998c4             91006081                ADD $24, R4, R1                                                                 
  analysis.go:1088      0x1007998c8             d0002b80                ADRP 5709824(PC), R0                                                            
  analysis.go:1088      0x1007998cc             91308000                ADD $3104, R0, R0                                                               
  analysis.go:1088      0x1007998d0             97e1d100                CALL runtime.convTnoptr(SB)            

So, this is a dup of golang/go#66732.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants