-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: "slice bounds out of range" crash in ExtractToNewFile #70553
Comments
I think the root cause here is a bad ast.File.FileStart (#70162), because the logic in gopls looks unimpeachable. I'll add more range-checking assertions to gopls so that we get more specific failure information in future. |
Change https://go.dev/cl/631675 mentions this issue: |
This CL adds defensive assertions to ExtractToNewFile, which experiences a crash due to out-of-bounds indexing. The logic looks sound, but clearly something is off. This CL also fixes a mistake in the logic added to parsego.Parse to work around golang/go#70162 (missing File.FileStart in go/parser), but I don't think that bug explains golang/go#70553 because it is concerned only with deeply broken files. Updates golang/go#70553 Updates golang/go#70162 Change-Id: Ie4f6fbbde2046023d7a3b865e5810bbed3be3118 Reviewed-on: https://go-review.googlesource.com/c/tools/+/631675 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/631676 mentions this issue: |
Also add back the x/tools replace directive. For golang/go#70301 Merge List: + 2024-11-26 68e4702 go/analysis/passes/printf: add missing call to Func.Origin + 2024-11-26 30a3bd9 gopls/internal/golang: refactor.extract.variable: allow all exprs + 2024-11-26 0edd1ab gopls/internal/cache/methodsets: refine crash for missing object path + 2024-11-25 07a58bc gopls/internal/golang: refine crash golang/go#70553 + 2024-11-25 c622026 completions/inference: infer polymorphic types in completions + 2024-11-25 dcfb0b6 gopls/internal/golang: change signature via renaming 'func' + 2024-11-25 bfcbc1b internal/refactor/inline: avoid unnecessary desugaring in selectors + 2024-11-25 b93a72a internal/refactor/inline: fix spurious caller mutation + 2024-11-25 41f04a0 internal/refactor/inline: fix comment movement due to added imports + 2024-11-25 0841661 internal/refactor/inline: avoid unnecessary interface conversions + 2024-11-25 68b67b4 gopls/internal/golang: support parameter movement refactorings + 2024-11-22 51e54e8 gopls/doc/features: enable and document source.addTest code action + 2024-11-22 458067f gopls/internal/golang: improve test package name selection for new file + 2024-11-22 68caf84 gopls/internal/golang: don't lose ... when split/joining variadics + 2024-11-21 1e0d4ee go/analysis/checker: disable Example on wasm + 2024-11-21 8b6e84b gopls/internal/crash: don't crash in xrefs on out of bound nodes + 2024-11-21 936a401 gopls/internal/golang: preserve copyright and build constraint + 2024-11-21 1ffc3a1 gopls/internal/test/marker: add defloc, to bind positions by definition + 2024-11-21 442d6be gopls/internal/test/marker: document named parameters + 2024-11-21 ae39b13 go/analysis/checker: a go/packages-based driver library + 2024-11-21 c3a6283 go/packages: undeprecate Load* style flags + 2024-11-20 9dff42e gopls/internal/golang/extract: preserve comments in extracted block + 2024-11-20 8c3ba8c internal/refactor: undo variadic elimination during substitution + 2024-11-20 3b0b264 internal/refactor: handle qualified names in inlined assignments + 2024-11-20 9311800 gopls/internal/test/marker: ignore diags in fixedbugs/issue59944.txt + 2024-11-20 c1aa79d gopls/internal/golang: fix gopls hover doc link + 2024-11-20 e751756 internal/analysisinternal: unify zero value function to typesinternal + 2024-11-20 a287481 internal/imports: test Source for go mod cache + 2024-11-19 9387a39 gopls/doc/contributing.md: update expectations + 2024-11-19 e08fcf7 gopls/internal/analysis/undeclaredname: merge into CodeAction + 2024-11-18 0c01408 internal/refactor/inline: avoid binding decl for name used by other args + 2024-11-18 63e03c3 gopls/internal/test/marker: generalize codeaction with named args + 2024-11-18 acc2a74 go/analysis/passes/copylock: enable unfortunate tests + 2024-11-18 39cb6f0 internal/facts: use alias type parameters and arguments during imports + 2024-11-18 9b9871d go/analysis/passes/copylock: test for noCopy for sync Map, Mutex, Once + 2024-11-18 a54bd37 gopls/internal/golang: don't try to inline dynamic calls + 2024-11-18 52eb446 internal/imports: adjust TestStdlibSelfImports pkg + 2024-11-18 b8ff201 gopls/internal/cache: refine bug reports for inconsistent dep view + 2024-11-18 e59fd36 go/ssa: use ZeroString unconditionally + 2024-11-18 60bc93d gopls/internal/cache: fix handling of cgo standalone files + 2024-11-18 ed19fc7 gopls/internal/test: synchronize notifications during commands + 2024-11-15 254baba gopls/internal/cache: failure to extract diagnostic fixes is an error + 2024-11-15 56ec111 gopls/internal/server: remove spurious Async in legacy RunGoVulncheck + 2024-11-14 b1c39aa gopls/internal/cache: use a named bool type for allowNetwork + 2024-11-14 c043599 gopls/internal/protocol: add DocumentURI.DirPath + 2024-11-14 29f4edb gopls/internal/cache: simplify usage of snapshot.GoCommandInvocation + 2024-11-14 3c20e3f gopls/internal/analysis/yield: analyzer for iterator (yield) mistakes + 2024-11-14 221e94d gopls/internal/cache: id command-line-arguments packages using GoFiles + 2024-11-14 84e9c33 gopls/internal/golang: more idiomatic result naming in extract + 2024-11-14 8bb5da3 gopls/internal/golang: special handling for input context.Context + 2024-11-14 b4332e0 gopls/internal/golang, go/ssa: remove unnamed input parameter + 2024-11-14 a8d0fa5 go/packages: call testenv.NeedsGoPackages for TestDirAndForTest + 2024-11-14 47a5f7d gopls/internal/golang: fix bad slice append in function extraction Change-Id: I2abfc8fd925da3b4ee5964e1cf32bb7fada0e688
Issue created by stacks.
This stack
fFKP7w
was reported by telemetry:crash/crash
runtime.gopanic:+69
runtime.goPanicSliceAcap:+2
golang.org/x/tools/gopls/internal/golang.ExtractToNewFile:+72
golang.org/x/tools/gopls/internal/server.(*commandHandler).ExtractToNewFile.func1:+1
golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3
golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+77
golang.org/x/tools/gopls/internal/server.(*commandHandler).ExtractToNewFile:+1
golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+81
golang.org/x/tools/gopls/internal/server.(*server).ResolveCodeAction:+21
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+46
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
The text was updated successfully, but these errors were encountered: