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

Fails to build error: variable 'cons_0' set but not used #316

Closed
mothran opened this issue Apr 17, 2023 · 7 comments
Closed

Fails to build error: variable 'cons_0' set but not used #316

mothran opened this issue Apr 17, 2023 · 7 comments

Comments

@mothran
Copy link

mothran commented Apr 17, 2023

When building a target project cargo afl build on the following setup I get the below error:

      stderr: "GNUmakefile.llvm:68: you are using an in-development llvm version - this might break llvm_mode!\nsrc/afl-fuzz-redqueen.c:1603:20: error: variable 'cons_0' set but not used [-Werror,-Wunused-but-set-variable]\n  u8  cons_ff = 0, cons_0 = 0;\n                   ^\n1 error generated.\nmake: *** [GNUmakefile:452: afl-fuzz] Error 1\n",
  }', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/afl-0.12.16/build.rs:72:5
  • clang version 15.0.7
  • LLD 15.0.7
  • Arch Linux 6.2.9-arch1-1
@smoelius
Copy link
Member

To be clear, afl.rs installs fine (i.e., cargo install afl completes without error)?

Can you share the project that causes the problem?

@mothran
Copy link
Author

mothran commented Apr 17, 2023

Yup cargo install -f afl work without issue:

   Replacing /home/user/.cargo/bin/cargo-afl
    Replaced package `afl v0.12.16` with `afl v0.12.16` (executable `cargo-afl`)

This is a brand new project from cargo new afl-test the adding:

[dependencies]
afl = "*"
url = "*"

To Cargo.toml and then Using the Url fuzzer from the book here: https://rust-fuzz.github.io/book/afl/tutorial.html

main.rs:

use afl::fuzz;

fn main() {
    fuzz!(|data: &[u8]| {
        if let Ok(s) = std::str::from_utf8(data) {
            let _ = url::Url::parse(&s);
        }
    });
}

The only difference from that is I am using a specific version of the rust-toolchain by adding the following file to the crate root: rust-toolchain.toml

[toolchain]
channel = "nightly-2022-10-28"
components = [ "rustfmt", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"

@smoelius
Copy link
Member

Could you try cargo afl build --release and see if the problem goes away?

I think what is happening is cargo afl build causes afl.rs's build script to run. Because the default profile is dev, DEBUG gets set to true. Then this becomes a duplicate of #202 (comment). This seems to be a problem when Clang is the compiler, but not otherwise.

Ideally, we would run the build script when afl.rs is being installed, but not when it is used as a dependency. However, this issue suggests there's no easy way to do that right now: rust-lang/cargo#4001

At present, I am inclined to go with @vkleen's original proposal, which was to remove the DEBUG environment variable unconditionally.

Does anyone reading this have any better ideas?

@mothran
Copy link
Author

mothran commented Apr 18, 2023

@smoelius Yep that worked!

It might be nice to make a note in the book / docs but this makes sense to me. It does cause some conflicts with check-on-save tooling like cargo check|clippy but I think thats a minor issue.

@smoelius
Copy link
Member

smoelius commented Apr 27, 2023

@mothran Earlier today, I published a new version of afl.rs that removes the DEBUG environment variable unconditionally.

Could I impose on you to install the new version and run your test again without the --release flag? I think it should work now.

@mothran
Copy link
Author

mothran commented Apr 27, 2023

@smoelius that worked for me, Thanks!

@mothran mothran closed this as completed Apr 27, 2023
@smoelius
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants