looppointer
looppointer copied to clipboard
panic
Looks like it panics on https://pkg.go.dev/google.golang.org/protobuf.
(13:41:56) ERROR: /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/external/org_golang_google_protobuf/internal/filedesc/BUILD.bazel:3:11: GoCompilePkg external/org_golang_google_protobuf/internal/filedesc/filedesc.a failed: (Exit 1): builder failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/org_golang_google_protobuf/internal/filedesc/build.go -src ... (remaining 57 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox
compilepkg: panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x100a62e4c]
goroutine 146 [running]:
go/ast.(*Object).Pos(0x2000?)
GOROOT/src/go/ast/scope.go:93 +0x1c
github.com/kyoh86/looppointer.(*Searcher).checkUnaryExpr(0x14000726c90, 0x1400012a3c0, {0x14000e8c000?, 0x10129c7e8?, 0x14000726a08?})
external/com_github_kyoh86_looppointer/looppointer.go:150 +0xec
github.com/kyoh86/looppointer.(*Searcher).Check(0x14000726c90, {0x100f7beb8?, 0x1400012a3c0?}, {0x14000e8c000?, 0x14000726a58?, 0x100974b4c?})
external/com_github_kyoh86_looppointer/looppointer.go:84 +0x128
github.com/kyoh86/looppointer.run.func1({0x100f7beb8?, 0x1400012a3c0?}, 0x68?, {0x14000e8c000?, 0x0?, 0x5f0?})
external/com_github_kyoh86_looppointer/looppointer.go:43 +0x54
golang.org/x/tools/go/ast/inspector.(*Inspector).WithStack(0x14000aa6030, {0x14000726cb8?, 0x3?, 0x101508130?}, 0x14000726c98)
external/org_golang_x_tools/go/ast/inspector/inspector.go:126 +0x188
github.com/kyoh86/looppointer.run(0x14001294000)
external/com_github_kyoh86_looppointer/looppointer.go:42 +0x14c
main.(*action).execOnce(0x140004fe360)
external/io_bazel_rules_go/go/tools/builders/nogo_main.go:306 +0x764
sync.(*Once).doSlow(0x0?, 0x0?)
GOROOT/src/sync/once.go:68 +0x10c
sync.(*Once).Do(...)
GOROOT/src/sync/once.go:59
main.(*action).exec(0x0?)
external/io_bazel_rules_go/go/tools/builders/nogo_main.go:250 +0x44
main.execAll.func1(0x0?)
external/io_bazel_rules_go/go/tools/builders/nogo_main.go:244 +0x50
created by main.execAll
external/io_bazel_rules_go/go/tools/builders/nogo_main.go:242 +0x48
@uhthomas Give me a code to reproduce it.
I got sources from github.com/protocolbuffers/protobuf-go and call loopointer but it did not panic.
$ go vet -vettool ./looppointer ./...
go: downloading github.com/google/go-cmp v0.5.5
# google.golang.org/protobuf/internal/impl_test
internal/impl/legacy_file_test.go:460:25: taking a pointer for the loop variable tt
internal/impl/legacy_file_test.go:460:35: taking a pointer for the loop variable tt
@mhindery if you have a code to reproduce, could you give me it?