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

Build Scripts should check command exit code in addition to invocation success #2035

Open
vringar opened this issue Apr 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@vringar
Copy link
Contributor

vringar commented Apr 10, 2024

Describe the bug

As far as I could tell from a quick search most Command invocations in build.rs files only use a single unwrap on the result of the status(). However, the first unwrap only covers a failure to invoke the command, not whether it completed successfully.
Mara Bos has confirmed this in this comment.

To Reproduce
Steps to reproduce the behavior:

  1. Don't install a required dependency to build qemu
  2. Run cargo build --no-default-features -p libafl_qemu
  3. Observe that the first error reported by the build script is Failed to read linkinfo.json as that is the "observable" error condition from the perspective of the build script.

Expected behavior

I would expect the error to be accurately attributed to the failing command.

Additional context

There are a couple of different ways this is handled in other buildscripts

assert!(
command.status().map_or(false, |s| s.success()),
"Couldn't build runtime crate! Did you remember to use nightly? (`rustup default nightly` to install)"
);

if status.success() {
println!("success to run ./build_nyx_support.sh");
} else {
panic!("fail to run ./build_nyx_support.sh");
}

But there are also a lot of unhandled cases elsewhere like

Command::new("git")
.arg("clone")
.arg(AFL_URL)
.status()
.unwrap();

.status()
.expect("Failed to build test harness");
}

@vringar vringar added the bug Something isn't working label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant