Skip to content

cmd/go: SIGSEGV in modload.Lookup when testing a file list with -covermode=atomic #81406

Open

Description

@d-enk

go version: reproduces since go1.24, still at tip (1.28-devel_49c3ea64). Works fine on 1.23 and earlier.

Repro (any module root):

go test -covermode=atomic main_test.go go.mod

Expected (1.23 and earlier):

named files must be .go files: go.mod

Actual:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0x8e8021]

goroutine 1 [running]:
cmd/go/internal/modload.Lookup(...)
	cmd/go/internal/modload/load.go:856
cmd/go/internal/load.loadPackageData.func1()
	cmd/go/internal/load/pkg.go:905
cmd/internal/par.(*Cache[...]).Do(...)
	cmd/internal/par/work.go:160
cmd/go/internal/load.loadPackageData(...)
	cmd/go/internal/load/pkg.go:899
cmd/go/internal/load.loadImport(...)
	cmd/go/internal/load/pkg.go:736
cmd/go/internal/load.EnsureImport(...)
	cmd/go/internal/load/pkg.go:3516
cmd/go/internal/test.runTest(...)
	cmd/go/internal/test/test.go:995

Version confirmation:

go1.23.0 test -covermode=atomic main_test.go go.mod
→ named files must be .go files: go.mod        (ok)
go1.27.1 test -covermode=atomic main_test.go go.mod
→ SIGSEGV                                      (regression)

Only -covermode=atomic triggers it (set/count/no-cover → clean error).
test.go:995 injects sync/atomic via EnsureImport(moduleLoader, ...) before
named-file validation; in file-list mode the module loader is nil →
nil deref in modload.Lookup (load.go:856).

Found via zsh EXTENDED_GLOB: unquoted -bench ^ expands ^ to the whole cwd
file list (incl. go.mod) — exactly this arg shape.

Activity

  1. thepudds commented on Sep 9, 2026

    @thepudds
    Member

    Probably not super useful in this case, but FWIW this bisected to 49b3ab0:

      first BAD:   49b3ab0d81 | 2024-11-17 14:32 | cmd/go: report all loading errors in tests as "setup failed"
      GOOD parent: 7020759859 | 2024-11-17 14:31 | cmd/go: implement "go build -json"
    
  2. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Sep 9, 2026
  3. gopherbot commented on Sep 13, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/831944 mentions this issue: cmd/go: avoid panic for invalid file lists with atomic coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions