Skip to content

Update libFuzzer fuzz instructions #3705

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

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

Prabhat1308
Copy link
Contributor

Without this flag , following the usual routine generates this error

Output
error: Fuzz targets need cfg=hashes_fuzz
  --> src/bin/msg_ping_target.rs:20:1
   |
20 | compile_error!("Fuzz targets need cfg=hashes_fuzz");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Fuzz targets need cfg=secp256k1_fuzz
  --> src/bin/msg_ping_target.rs:23:1
   |
23 | compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `lightning-fuzz` (bin "msg_ping_target") due to 2 previous errors
Error: failed to build fuzz script: ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Cpasses=sancov-module -Cllvm-args=-sanitizer-coverage-level=4 -Cllvm-args=-sanitizer-coverage-inline-8bit-counters -Cllvm-args=-sanitizer-coverage-pc-table -Cllvm-args=-sanitizer-coverage-trace-compares --cfg fuzzing -Clink-dead-code -Zsanitizer=address -Cdebug-assertions -C codegen-units=1" "cargo" "build" "--manifest-path" "/Users/prabhatverma/projects/rust-lightning/fuzz/Cargo.toml" "--target" "aarch64-apple-darwin" "--release" "--config" "profile.release.debug=true" "--features" "libfuzzer_fuzz" "--bin" "msg_ping_target"

After introducing this , normal fuzz operation is observed

INFO: Seed: 4260578952
INFO: Loaded 1 modules   (614 inline 8-bit counters): 614 [0x1027ee270, 0x1027ee4d6), 
INFO: Loaded 1 PC tables (614 PCs): 614 [0x1027ee4d8,0x1027f0b38), 
INFO:        0 files found in /Users/prabhatverma/projects/rust-lightning/fuzz/corpus/msg_ping_target
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2      INITED cov: 6 ft: 6 corp: 1/1b exec/s: 0 rss: 51Mb
#4194304        pulse  cov: 6 ft: 6 corp: 1/1b lim: 4096 exec/s: 1398101 rss: 461Mb
#8388608        pulse  cov: 6 ft: 6 corp: 1/1b lim: 4096 exec/s: 1398101 rss: 465Mb
#16777216       pulse  cov: 6 ft: 6 corp: 1/1b lim: 4096 exec/s: 1398101 rss: 468Mb
^C
==57544== libFuzzer: run interrupted; exiting

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Apr 3, 2025

I've assigned @valentinewallace as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.11%. Comparing base (8d8b4ea) to head (3341d7c).
Report is 456 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3705      +/-   ##
==========================================
+ Coverage   88.55%   89.11%   +0.56%     
==========================================
  Files         149      155       +6     
  Lines      114470   121678    +7208     
  Branches   114470   121678    +7208     
==========================================
+ Hits       101365   108430    +7065     
+ Misses      10606    10584      -22     
- Partials     2499     2664     +165     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -61,6 +61,7 @@ To run fuzzing using `cargo-fuzz / libFuzzer`, run

```shell
rustup install nightly # Note: libFuzzer requires a nightly version of rust.
export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this as well, but it seems I don't need to add --cfg=fuzzing. Does it work for you without that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo fuzz should add cfg=fuzzing automatically for us, but it also doesn't really hurt for us to add it manually. Its also required when running cargo test in the fuzz crate, so IMO its fine to have it be explicit.

@TheBlueMatt
Copy link
Collaborator

Gonna go ahead and land this since there's little reason to nitpick over a redundant cfg.

@TheBlueMatt TheBlueMatt merged commit e56c14f into lightningdevkit:main Apr 4, 2025
25 of 27 checks passed
@Prabhat1308 Prabhat1308 deleted the pv/update_fuzz_instr branch April 5, 2025 17:17
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.

4 participants