Skip to content

crash when using gazelle generation_mode:update_only #2707

Closed
@jbedard

Description

@jbedard

🐞 bug report

Description

The next version of gazelle will include generation_mode to allow only updating existing BUILD files and never creating new ones. This means language callbacks such as Configure and GenerateRules will not be invoked for directories that do not already have a BUILD file.

Today rules_python/gazelle assumes GenerateRules is invoked for every single directory and crashes if it was not invoked for a parent directory.

Short term: we should not assume GenerateRules was invoked for every directory.

Long term: I think python_generation_mode: project can be replace with generation_mode: update_only, although there will be minor differences (the user must touch BUILD) and it will be a breaking change.

🔬 Minimal Reproduction

BUILD    <--- put `# gazelle:generation_mode update_only` + enable rules_python/gazelle
libs/
   a/BUILD

🔥 Exception or Error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x100e90d08]

goroutine 1 [running]:
github.com/bazelbuild/rules_python/gazelle/pythonconfig.(*Config).NewChild(...)
	external/com_github_bazelbuild_rules_python_gazelle/pythonconfig/pythonconfig.go:213
github.com/bazelbuild/rules_python/gazelle/python.(*Configurer).Configure(0x10338d9e0, 0x14010b068f0, {0x14010b206d8, 0x14}, 0x14010b3c5a0)
	external/com_github_bazelbuild_rules_python_gazelle/python/configure.go:98 +0x1c8
github.com/bazelbuild/bazel-gazelle/walk.configure({0x140005f7400?, 0x8?, 0x14?}, 0x1400198a9a8?, 0x14010b068f0, {0x14010b206d8, 0x14}, 0x14010b3c5a0)
	external/bazel_gazelle/walk/walk.go:373 +0x78
github.com/bazelbuild/bazel-gazelle/walk.visit(0x14010b068f0, {0x140005f7400, 0x8, 0x8}, 0x1400198a9a8, 0x140016fdc80, 0x1400191ad00, 0x1400198b4b0, {0x14010b206d8, 0x14}, ...)
	external/bazel_gazelle/walk/walk.go:172 +0x3ac
github.com/bazelbuild/bazel-gazelle/walk.visit(0x14010b06820, {0x140005f7400, 0x8, 0x8}, 0x1400198a9a8, 0x140016fdc80, 0x1400186aa80, 0x1400198b4b0, {0x14010b1c868, 0x4}, ...)
	external/bazel_gazelle/walk/walk.go:235 +0xe40
github.com/bazelbuild/bazel-gazelle/walk.visit(0x140013d48f0, {0x140005f7400, 0x8, 0x8}, 0x1400198a9a8, 0x140016fdc80, 0x140016f1880, 0x1400198b4b0, {0x0, 0x0}, ...)
	external/bazel_gazelle/walk/walk.go:235 +0xe40
github.com/bazelbuild/bazel-gazelle/walk.Walk(0x140013d48f0, {0x140005f7400, 0x8, 0x8}, {0x140013e2fc0, 0x1, 0x1}, 0x0, 0x1400198b4b0)
	external/bazel_gazelle/walk/walk.go:128 +0x17c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions