golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.86k stars 17.65k forks source link

x/tools/go/packages: panic in testParseFileModifyAST #32833

Open bcmills opened 5 years ago

bcmills commented 5 years ago

Observed in https://build.golang.org/log/269df758e38c6dcc180de71777773231b6f98014 (on windows-amd64-2016):

panic: runtime error: index out of range [recovered]
    panic: runtime error: index out of range

goroutine 512 [running]:
testing.tRunner.func1(0xc0001bab00)
    C:/workdir/go/src/testing/testing.go:830 +0x399
panic(0x6e5800, 0x9959e0)
    C:/workdir/go/src/runtime/panic.go:522 +0x1c3
golang.org/x/tools/go/packages_test.testParseFileModifyAST(0xc0001bab00, 0x7a5740, 0x9bbf10)
    C:/workdir/gopath/src/golang.org/x/tools/go/packages/packages_test.go:852 +0x4b9
golang.org/x/tools/go/packages/packagestest.TestAll.func1(0xc0001bab00)
    C:/workdir/gopath/src/golang.org/x/tools/go/packages/packagestest/export.go:101 +0x6f
testing.tRunner(0xc0001bab00, 0xc000047e60)
    C:/workdir/go/src/testing/testing.go:865 +0xc7
created by testing.(*T).Run
    C:/workdir/go/src/testing/testing.go:916 +0x361
FAIL    golang.org/x/tools/go/packages  17.895s

It's not obvious to me whether this is a secondary symptom of the race reported in #31749 or an unrelated bug.

CC @matloob @ianthehat

matloob commented 5 years ago

Have we been able to reproduce this? Does this only happen on Windows?