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) [panic: slice out of bounds, v0.15.3/go1.22.2] #3352

Closed
rusq opened this issue Apr 20, 2024 · 3 comments
Milestone

Comments

@rusq
Copy link

rusq commented Apr 20, 2024

Hey team, I tried to add as much information as I could, but please let me know if any additional diag is needed.

Reproduce

  1. Install goyacc

    go install golang.org/x/tools/cmd/goyacc@latest
    
  2. Run the following command to generate y.go and y.output

    goyacc slacktime.y
    
  3. Open "y.go" file in VSCode.

  4. Observe the Gopls crash.

To confirm:

  1. Restart the Gopls server
  2. It crashes again

Notes

slacktime.y is C version of the grammar file, so "y.go" will not work straight away. I was just planning to adapt it to Goyacc, but ran into this issue. I suspect it is similar to #3351 which was recently opened as well.

I'm attaching an archive of the project files. There's no sensitive information, it's just an experimental code.

  • the gopls log is in gopls.log.
  • the reproduction steps are duplicated in REPRODUCE.md, should you need them
  • generate-y.go.sh contains the command to generate y.go, should it be required.
  • "slacktime.l" has nothing to do with this, just there for completeness.
  • I have not included irrelevant slacktime.h files nor the implementation of functions handle_slacktime, which is irrelevant and would only add entropy, but can share them as well if needed.

HERE WE GO:
gopls-issue-project.tar.gz

Thank you, and please let me know if anything else is required?

Orignial Report

gopls version: v0.15.3/go1.22.2
gopls flags:
update flags: proxy
extension version: 0.41.2
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Sat, 20 Apr 2024 04:36:43 GMT
restart history:
Sat, 20 Apr 2024 04:35:52 GMT: activation (enabled: true)
Sat, 20 Apr 2024 04:36:42 GMT: installation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Important

I have opened the y.go file from the attached archive. Y.go file is the go file generated by goyacc tool. See Reproduce above.

panic: runtime error: slice bounds out of range [3:2]

goroutine 125 [running]:
golang.org/x/tools/gopls/internal/protocol.(*Mapper).LineCol8Position(0xc0001d0f00, 0x2, 0x0)
	  mapper.go:151  0x1a5
golang.org/x/tools/gopls/internal/cache.goPackagesErrorDiagnostics.func1({{0xc000240c40, 0xd}, {0xc000800280, 0x1c}, 0x1}, 0x1c%3F, {0x676e900, 0xc0001abb00}, {0x6776d00, 0xc00060a0f0})
	  errors.go:58  0x145
golang.org/x/tools/gopls/internal/cache.goPackagesErrorDiagnostics({0x6776d00, 0xc00060a0f0}, {{0xc000240c40, 0xd}, {0xc000800280, 0x1c}, 0x1}, 0xc000346100, {0x676e900, 0xc0001abb00})
	  errors.go:69  0xf5
golang.org/x/tools/gopls/internal/cache.computeLoadDiagnostics({0x6776d00, 0xc00060a0f0}, 0xc0001abb00, 0xc000346100)
	  load.go:541  0x185
golang.org/x/tools/gopls/internal/cache.(*packageHandleBuilder).buildPackageHandle(0xc000230140, {0x6776d00, 0xc00060a0f0}, 0xc00060a0a0)
	  check.go:1129  0x2b7
golang.org/x/tools/gopls/internal/cache.(*Snapshot).getPackageHandles.func2.1()
	  check.go:932  0xce
golang.org/x/sync/errgroup.(*Group).Go.func1()
	  errgroup.go:78  0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 179
	  errgroup.go:75  0x96
gopls stats -anon gopls stats -anon failed after 136 ms. Please check if gopls is killed by OS.

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.

@gopherbot gopherbot added this to the Untriaged milestone Apr 20, 2024
@rusq
Copy link
Author

rusq commented Apr 20, 2024

Probably this should have been opened in gopls issues, but I blame extension for opening this page when I pressed "report"!

@rusq
Copy link
Author

rusq commented Apr 20, 2024

I have tested with the previous versions, here are my results:

gopls version Works?
v0.14.2
v0.15.0
v0.15.1
v0.15.2

GoPLS v0.14.2 output (that did not crash):

[Info  - 15:12:57] 2024/04/20 15:12:57 go info for /Users/anon/wp/_experiments/_c/goslackdump-time
(go dir /Users/anon/wp/_experiments/_c/goslackdump-time)
(go version go version go1.22.2 darwin/amd64)
(valid build configuration = true)
(build flags: [])
(selected go env: [GO111MODULE=, GOCACHE=/Users/anon/Library/Caches/go-build, GOFLAGS=, GOMODCACHE=/Users/anon/go/pkg/mod, GOPATH=/Users/anon/go, GOPRIVATE=bitbucket.org/dbvisitsoftware,github.com/rusq,bitbucket.org/128,bitbucket.org/puritron,github.com/vend, GOROOT=/usr/local/Cellar/go/1.22.2/libexec, GOWORK=])


[Info  - 15:12:57] 2024/04/20 15:12:57 go/packages.Load #1
	snapshot=0
	directory=file:///Users/anon/wp/_experiments/_c/goslackdump-time
	query=[/Users/anon/wp/_experiments/_c/goslackdump-time/... builtin]
	packages=2

[Info  - 15:12:57] 2024/04/20 15:12:57 go/packages.Load #1: updating metadata for 1 packages

[Error - 15:12:57] 2024/04/20 15:12:57 unable to compute positions for parse errors: no parsed file for file:///Users/anon/wp/_experiments/_c/goslackdump-time/slacktime.y in goslackdumptime
	package="goslackdumptime"

[Error - 15:12:57] 2024/04/20 15:12:57 imports fixes: AllImportsFixes: /Users/anon/wp/_experiments/_c/goslackdump-time/slacktime.y:2: illegal character U+0023 '#'
	file="/Users/anon/wp/_experiments/_c/goslackdump-time/y.go"

[Error - 15:12:57] 2024/04/20 15:12:57 unable to compute positions for parse errors: no parsed file for file:///Users/anon/wp/_experiments/_c/goslackdump-time/slacktime.y in goslackdumptime
	package="goslackdumptime"

@findleyr
Copy link
Member

Thank you for the reproducer and detailed report. This looks like a dupe of golang/go#66875, so I'll close it in favor of that issue.

The reproducer will make this much easier to fix.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
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