-
Notifications
You must be signed in to change notification settings - Fork 19k
x/tools/gopls: DidChangeWatchedFiles: impossible crash in growslice #75465
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone 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.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins
Milestone
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone 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.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins
Type
Fields
Give feedbackNo fields configured for issues without a type.
Issue created by stacks.
Another impossible crash: the compiler generates code to load the
*Snapshottype descriptor from rodata in R4, then calls growslice, which experiences a SEGV while loading from this register at L194.Unlike all previous crashes, which have been loads from SP or g, this one is an ordinary register. I'm struggling to think of a realistic scenario in which an application bug (e.g. data race, misuse of unsafe) could cause this problem. It's one thing for buggy code to clobber arbitrary memory, but this crash means that a register has been corrupted. R4 has somehow been clobbered between the load from rodata (which can't have been written) and the load at L194, with no intervening function calls. I suppose it's possible that the runtime suspended the g in between, and the memory where the g's register file was saved was corrupted, but that seems very unlikely, not least because there is nothing that would synchronously invoke the scheduler in this handful of instructions.
I'm starting to suspect that this is a bug not in the application, but in the runtime or hardware. @prattmic
This stack
fcv6BQwas reported by telemetry:crash/crashruntime.throw:+9,+0x37runtime.sigpanic:+33,+0x223runtime.growslice:+17,+0x20golang.org/x/tools/gopls/internal/cache.(*Session).ExpandModificationsToDirectories:+9,+0x17fgolang.org/x/tools/gopls/internal/server.(*server).didModifyFiles:+34,+0x2ebgolang.org/x/tools/gopls/internal/server.(*server).DidChangeWatchedFiles:+13,+0x1fbgolang.org/x/tools/gopls/internal/protocol.serverDispatch:+634,+0x5437golang.org/x/tools/gopls/internal/lsprpc.(*StreamServer).ServeStream.ServerHandler.func4:+5,+0x73golang.org/x/tools/gopls/internal/lsprpc.(*StreamServer).ServeStream.handshaker.func5:+52,+0x68fgolang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2,+0xbfgolang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3,+0x8fruntime.goexit:+0,+0x3