bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.19k stars 378 forks source link

nil pointer deference with update-repos + go.work + bzlmod #1895

Closed rockwotj closed 1 month ago

rockwotj commented 1 month ago

What version of gazelle are you using?

0.38.0

What version of rules_go are you using?

0.49.0

What version of Bazel are you using?

7.3.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

$ uname -a
Linux redpanda 6.8.0-41-generic #41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

What did you do?

bazel run //:gazelle -- update-repos -from_file=go.work  -bzlmod

In this branch: https://github.com/rockwotj/redpanda/tree/gazelle

What did you expect to see?

Command success

What did you see instead?

INFO: Running command line: bazel-bin/gazelle-update-repos update-repos '-from_file=go.work' -bzlmod
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x906eb2]

goroutine 1 [running]:
github.com/bazelbuild/bazel-gazelle/language/go.migrateLibraryEmbed(0xffffffffffffffff?, 0x0?)
        external/gazelle~/language/go/fix.go:161 +0x12
github.com/bazelbuild/bazel-gazelle/language/go.(*goLang).Fix(0x0?, 0xc000000300, 0x0)
        external/gazelle~/language/go/fix.go:28 +0x27
main.updateRepos({0xc00003601a, 0x1c}, {0xc000024120, 0x2, 0x2})
        external/gazelle~/cmd/gazelle/update-repos.go:183 +0xc5f
main.run({0xc00003601a?, 0x1c?}, {0xc000024110?, 0x3?, 0x3?})
        external/gazelle~/cmd/gazelle/gazelle.go:99 +0x1c5
main.main()
        external/gazelle~/cmd/gazelle/gazelle.go:72 +0xf5
rockwotj commented 1 month ago

Seems to work if there is an empty WORKSPACE file...