Skip to content

cmd/go: frequent SEGV without stderr text [darwin, go1.26+tip] #78627

@adonovan

Description

@adonovan

For months various gopls tests have been flaky in CI every day following a pattern in which invocations of the go command (e.g. list env, version) fail with SIGSEGV and no output. See for example the most recent dozens of notes on #75107. The failures are always on darwin but affect both amd64 and arm64. Both go1.26 and tip toolchains are affected. (Ignore the handful of linux, mips, etc notes, which are outliers not following this pattern.)

The details below imply that it is the go command itself that is signaled. Why is this happening? Why is it not printing a backtrace?

Here is a typical example:

              failed to load view for file:///Volumes/Work/s/w/ir/x/t/Testcodeactioninline-lhs-var.txt4059987421/001/work: err: signal: segmentation fault: stderr:

The "failed to load view" error comes from server.addFolders in gopls. The prefix of the error string indicates that it came from server.addView. From there it must have come from this return tree:

        - opts, err := s.fetchFolderOptions(ctx, dir) // DEAD END: all errors have distinct prefix 
        - folder, err := s.newFolder(ctx, dir, name, opts) 
          - FetchEnv
            - loadGoEnv
              - gocommand.Runner.Run // possible 
            - gocommand.GoVersion
              - gocommand.Runner.Run // possible
            - gocommand.GoVersionOutput
              - gocommand.Runner.Run // possible
        - _, snapshot, release, err := s.session.NewView(ctx, folder) 
           - defineView 
             - findRootPattern // DEAD END: can only fail due to context cancelation

All viable leaves are in gocommand.Runner.Run, which is consistent with the text of the error message string produced by Invocation.runWithFriendlyError. The error text implies that friendlyError="signal: segmentation fault" and stderr="". friendlyError comes from Invocation.run, thence from runCmdContext, cmd.Wait (not os.Pipe). From there it almost certainly came from os.Process.Wait: it looks to be an ExitError for a process state of signaled by SEGV.

So the go command itself (not one of its child processes) suffered a segmentation fault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.Go Command Working GroupGoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions