Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bartoszpop opened this issue May 1, 2024 · 0 comments · Fixed by #1872
Labels
gazelle Gazelle plugin related issues type: bug

Comments

@bartoszpop
Copy link
Contributor

bartoszpop commented May 1, 2024

🐞 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 added a commit to bartoszpop/rules_python that referenced this issue May 1, 2024
bartoszpop added a commit to bartoszpop/rules_python that referenced this issue May 3, 2024
bartoszpop added a commit to bartoszpop/rules_python that referenced this issue May 3, 2024
…r: invalid memory address or nil pointer dereference" (bazelbuild#1871)
@aignas aignas added type: bug gazelle Gazelle plugin related issues labels May 15, 2024
github-merge-queue bot pushed a commit that referenced this issue May 19, 2024
…emory address or nil pointer dereference" (#1872)

This pull request fixes `bazel run gazelle` failing on Windows with
"panic: runtime error: invalid memory address or nil pointer
dereference" if there is a path with at least 2-levels deep directory.

Fixes #1871

---------

Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gazelle Gazelle plugin related issues type: bug
Projects
None yet
2 participants