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

Use absolute path to fuzz_target! macro in macro recursion #84

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

Xiretza
Copy link
Contributor

@Xiretza Xiretza commented Aug 24, 2021

For fuzz targets that use libfuzzer_sys::fuzz_target!(|arg: &[u8]| {}) directly without #[macro_use]ing libfuzzer_sys, the compilation failed:

error: cannot find macro `fuzz_target` in this scope
   --> [$HOME]/.cargo/registry/src/github.com-1ecc6299db9ec823/libfuzzer-sys-0.4.2/src/lib.rs:161:9
    |
137 | / macro_rules! fuzz_target {
138 | |     (|$bytes:ident| $body:block) => {
139 | |         /// Auto-generated function
140 | |         #[no_mangle]
...   |
161 | |         fuzz_target!(|$data| $body);
    | |         ^^^^^^^^^^^
...   |
207 | |     };
208 | | }
    | |_- in this expansion of `libfuzzer_sys::fuzz_target!`
    |
   ::: fuzz_targets/bare.rs:3:1
    |
3   | / libfuzzer_sys::fuzz_target!(|data: &[u8]| {
4   | |     // fuzzed code goes here
5   | | });
    | |___- in this macro invocation
    |
    = note: consider importing this macro:
            libfuzzer_sys::fuzz_target

For fuzz targets that use `libfuzzer_sys::fuzz_target!(|arg: &[u8]| {})` directly
without `#[macro_use]`ing `libfuzzer_sys`, the compilation failed:

error: cannot find macro `fuzz_target` in this scope
   --> [$HOME]/.cargo/registry/src/github.com-1ecc6299db9ec823/libfuzzer-sys-0.4.2/src/lib.rs:161:9
    |
137 | / macro_rules! fuzz_target {
138 | |     (|$bytes:ident| $body:block) => {
139 | |         /// Auto-generated function
140 | |         #[no_mangle]
...   |
161 | |         fuzz_target!(|$data| $body);
    | |         ^^^^^^^^^^^
...   |
207 | |     };
208 | | }
    | |_- in this expansion of `libfuzzer_sys::fuzz_target!`
    |
   ::: fuzz_targets/bare.rs:3:1
    |
3   | / libfuzzer_sys::fuzz_target!(|data: &[u8]| {
4   | |     // fuzzed code goes here
5   | | });
    | |___- in this macro invocation
    |
    = note: consider importing this macro:
            libfuzzer_sys::fuzz_target
@fitzgen fitzgen merged commit fcf3b18 into rust-fuzz:master Aug 24, 2021
@fitzgen
Copy link
Member

fitzgen commented Aug 24, 2021

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants