rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

Gazelle fails on Windows with "panic: runtime error: invalid memory address or nil pointer dereference"

Open bartoszpop opened this issue 1 year ago • 0 comments

🐞 bug report

Affected Rule

The issue is caused by the rule:

rules_python_gazelle_plugin

Is this a regression?

No

Description

bazel run gazelle fails on Windows with the below error. As per Python Gazelle plugin:

Gazelle will walk up the filesystem from a Python file to find this metadata, looking for a file called gazelle_python.yaml in an ancestor folder of the Python code.

and because pythonconfig.go#ParentForPackage delegates to filepath.Dir(pkg) to replace the separator character "\" with "/", hence for a 2-levels deep path, e.g. rootDir\nestedDir1\nestedDir2, a parent is searched with "/" (rootDir/nestedDir1) but Configs contains a key with "\" (rootDir\nestedDir1).

🔬 Minimal Reproduction

Run rules_python_gazelle_plugin on Windows in a project with at least 2-levels deep directory structure.

🔥 Exception or Error

INFO: Running command line: bazel-bin/external/bp_bazel/tools/gazelle/gazelle.exe
INFO: Build Event Protocol files produced successfully.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x7c3122]

goroutine 1 [running]:
github.com/bazelbuild/rules_python/gazelle/pythonconfig.(*Config).NewChild(...)
	external/rules_python_gazelle_plugin/pythonconfig/pythonconfig.go:173
github.com/bazelbuild/rules_python/gazelle/python.(*Configurer).Configure(0xc00036a801?, 0xc0001a4900, {0xc000591a40, 0x18}, 0x0)
	external/rules_python_gazelle_plugin/python/configure.go:92 +0x222
github.com/bazelbuild/bazel-gazelle/walk.configure({0xc00022dcc0, 0xa, 0x18?}, 0xc000149080?, 0xc0001a4840?, {0xc000591a40, 0x18}, 0x0)
	external/bazel_gazelle/walk/walk.go:289 +0x383
github.com/bazelbuild/bazel-gazelle/walk.Walk.func1(0xc0001a4840, {0xc000149080, 0x44}, {0xc000591a40, 0x18}, 0x1)
	external/bazel_gazelle/walk/walk.go:145 +0x2d6
github.com/bazelbuild/bazel-gazelle/walk.Walk.func1(0xc0001a4780, {0xc000525680, 0x3c}, {0xc0001203b0, 0x10}, 0x1)
	external/bazel_gazelle/walk/walk.go:169 +0x8b7
github.com/bazelbuild/bazel-gazelle/walk.Walk.func1(0xc0001a4300, {0xc0003f2b40, 0x34}, {0xc000120300, 0x8}, 0x1)
	external/bazel_gazelle/walk/walk.go:169 +0x8b7
github.com/bazelbuild/bazel-gazelle/walk.Walk.func1(0xc0001a4300, {0xc0001428d0, 0x2b}, {0x0, 0x0}, 0x0)
	external/bazel_gazelle/walk/walk.go:169 +0x8b7
github.com/bazelbuild/bazel-gazelle/walk.Walk(0xc0001a4300, {0xc00022dcc0?, 0xa, 0xa}, {0xc000111a40, 0x1, 0x1}, 0x0, 0xc0001d5648)
	external/bazel_gazelle/walk/walk.go:179 +0x231
main.runFixUpdate({0xc000142690, 0x2b}, 0xc000120080?, {0xc00011a390, 0x0, 0x0})
	external/bazel_gazelle/cmd/gazelle/fix-update.go:325 +0xdc5
main.run({0xc000142690?, 0x2b?}, {0xc00011a390?, 0x1?, 0x1?})
	external/bazel_gazelle/cmd/gazelle/gazelle.go:95 +0x1dd
main.main()
	external/bazel_gazelle/cmd/gazelle/gazelle.go:72 +0xf5

🌍 Your Environment

Operating System:

  
Windows 11
  

Output of bazel version:

  
Bazelisk version: v1.18.0
Build label: 7.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Mar 21 18:11:32 2024 (1711044692)
Build timestamp: 1711044692
Build timestamp as int: 1711044692

  

Rules_python version:

  
0.31.0
  

Anything else relevant?

bartoszpop avatar May 01 '24 13:05 bartoszpop