bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
651 stars 412 forks source link

panic in process_wrapper #1209

Closed UebelAndre closed 2 years ago

UebelAndre commented 2 years ago

Earlier today I ran into the following error when just running bazel test //... on https://github.com/bazelbuild/rules_rust/commit/26e01c838679c8c0c52f4a82a7c973a3f5713960.

ERROR: /Users/user/Code/rules_rust/tools/rust_analyzer/BUILD.bazel:4:12: Clippy tools/rust_analyzer/gen_rust_project.clippy.ok failed: (Exit 101): process_wrapper failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/util/process_wrapper/process_wrapper --arg-file ... (remaining 82 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', util/process_wrapper/main.rs:78:24

The best repo I'm able to come up with is by running the following command

bazel clean && bazel test //tools/rust_analyzer:gen_rust_project_clippy --noremote_accept_cached

I'm running Bazel 5.0.0 on my Mac.

UebelAndre commented 2 years ago

cc @gigaroby @hlopko

gigaroby commented 2 years ago

Hey @UebelAndre, mind trying the PR I just sent to fix (or at least get more debug info) for this?

UebelAndre commented 2 years ago

@gigaroby With the changes in https://github.com/bazelbuild/rules_rust/pull/1214 I got the following

user@Users-MacBook-Pro rules_rust % bazel clean --expunge && bazel test //tools/rust_analyzer:gen_rust_project_clippy --noremote_accept_cached
INFO: Invocation ID: 30d1a7b0-aa83-4cca-bd88-13e938a67742
INFO: Starting clean.
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 888bd5a6-97ba-442c-9fbe-5aa740d2a48a
INFO: Analyzed target //tools/rust_analyzer:gen_rust_project_clippy (103 packages loaded, 3401 targets configured).
INFO: Found 1 target and 0 test targets...
ERROR: /Users/user/Code/rules_rust/tools/rust_analyzer/BUILD.bazel:4:12: Clippy tools/rust_analyzer/gen_rust_project.clippy.ok failed: (Exit 1): process_wrapper failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/util/process_wrapper/process_wrapper --arg-file ... (remaining 82 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
process wrapper error: subprocess does not have an exit code. core_dumped: false, signal: Some(6), stopped_signal: None
Target //tools/rust_analyzer:gen_rust_project_clippy failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 66.955s, Critical Path: 36.16s
INFO: 183 processes: 117 internal, 66 darwin-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
gigaroby commented 2 years ago

I can't repro this on linux, will try on my osx machine soon.

illicitonion commented 2 years ago

I reprod on macOS the first time I ran it, but can't repro again, no matter how much cleaning I do...

gigaroby commented 2 years ago

@illicitonion is that with or without the changes in #1214?

illicitonion commented 2 years ago

Without - I tried reproing with but also didn't get a failure.

UebelAndre commented 2 years ago

I seem to get it pretty consistently both with and without the changes. @illicitonion are you running the exact command I posted?

bazel clean --expunge && bazel test //tools/rust_analyzer:gen_rust_project_clippy --noremote_accept_cached

For some reason the --expunge does seem to play a factor here

illicitonion commented 2 years ago

Yep, exact command, can't repro after the first attempt... Very weird!

scentini commented 2 years ago

I can't repro at HEAD with Bazel 5.1.0, macOS. @UebelAndre could you provide the failing command line?

UebelAndre commented 2 years ago

@scentini Hey, is this what you want? https://github.com/bazelbuild/rules_rust/issues/1209#issuecomment-1076548442

scentini commented 2 years ago

Nah, i'd like to compare the arguments of the command that failed with mine. bazel clean --expunge && bazel test //tools/rust_analyzer:gen_rust_project_clippy -s --noremote_accept_cached should give you what I want, or alternatively bazel aqery //tools/rust_analyzer:gen_rust_project_clippy.

UebelAndre commented 2 years ago

Nah, i'd like to compare the arguments of the command that failed with mine. bazel clean --expunge && bazel test //tools/rust_analyzer:gen_rust_project_clippy -s --noremote_accept_cached should give you what I want, or alternatively bazel aqery //tools/rust_analyzer:gen_rust_project_clippy.

Sorry for the delay, my GitHub notifications have been weird and not actually notifying me of activity. The aquery gives nothing because the clippy build targets don't have actions and I'm now not able to reproduce the issue using the command 😞. Sometime this week I'll tinker some more to find a better repro.

snowp commented 2 years ago

I ran into this and spent some time debugging on macos. When running clippy directly from within the bazel sandbox (not via the process_wrapper), I got the following error:

azel-out/darwin-fastbuild/bin/loop/test/rust' --test -Dwarnings
clippy-driver(35435,0x305cb2000) malloc: *** error for object 0x600002a8d600: pointer being realloc'd was not allocated
clippy-driver(35435,0x305cb2000) malloc: *** set a breakpoint in malloc_error_break to debug

which lead me to this https://github.com/rust-lang/rust-clippy/issues/8470, so it appears like this issue might be fixed in clippy 1.60 (my build was using 1.59)

EDIT: Bumping the rust toolchain version to 1.60 seems to resolve it for me, though I think the clippy crash isn't 100% reproducible

UebelAndre commented 2 years ago

Closing this out since the issue appears to be resolved post Rust 1.60