Skip to content

Comments

Fuzz stdin support#4430

Merged
TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
joostjager:fuzz-prep
Feb 23, 2026
Merged

Fuzz stdin support#4430
TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
joostjager:fuzz-prep

Conversation

@joostjager
Copy link
Contributor

@joostjager joostjager commented Feb 20, 2026

Add stdin_fuzz feature support to all fuzz targets, allowing test cases to be replayed via stdin when built with --features stdin_fuzz. This is documented in a new section in the fuzz README.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 20, 2026

👋 Thanks for assigning @TheBlueMatt 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.

TARGET_NAME_test(&data, lightning_fuzz::utils::test_logger::Stdout {});
});
if res.is_err() {
std::process::exit(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explain why this is required? panicing in fn main() should cause the process to exit, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It didn't because the build didn't use panic=abort. Pushed a commit that adds this.

@joostjager joostjager changed the title Fuzz target improvements: stdin support and chanmon_consistency fixes Fuzz stdin support Feb 20, 2026
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.87%. Comparing base (153e57e) to head (69e2d8c).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4430      +/-   ##
==========================================
- Coverage   85.90%   85.87%   -0.04%     
==========================================
  Files         156      159       +3     
  Lines      103965   104302     +337     
  Branches   103965   104302     +337     
==========================================
+ Hits        89316    89573     +257     
- Misses      12128    12231     +103     
+ Partials     2521     2498      -23     
Flag Coverage Δ
tests 85.87% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@joostjager
Copy link
Contributor Author

Verified all fuzzer frontends work with the changes:

  • honggfuzz: CI
  • stdin_fuzz: manual run
  • libfuzzer: manual run on macOS
  • AFL: manual run in Docker on macOS

@joostjager joostjager force-pushed the fuzz-prep branch 2 times, most recently from 613cef0 to c9876bc Compare February 23, 2026 13:38
…dylib

This commit makes three related changes to the fuzz infrastructure:

1. Set panic=abort on both dev and release profiles, and remove the
   dylib crate type (keeping rlib and staticlib). The dylib crate type
   was added in e28fd78 (2019) for a C-callable harness that was
   never implemented. Removing dylib is what enables panic=abort,
   since Rust forces panic=unwind on dylib crates. staticlib is
   retained as it is compatible with panic=abort.

2. Add stdin_fuzz support: a new Stdout logger, updated target template
   so that stdin_fuzz calls _test() with Stdout logging, and updated
   README with usage instructions. This allows reproducing crashes via
   piped input, useful for git bisect and AI-assisted debugging.

3. Update all fuzzer frontends (AFL, honggfuzz, libfuzzer, stdin_fuzz)
   to call the _test() functions directly instead of going through the
   _run() C wrappers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joostjager
Copy link
Contributor Author

I restored the staticlib crate type and targets.h header. I would have preferred to remove them since they serve no known users and require manually adding a _run method to each target, but that felt like a separate discussion.

@joostjager joostjager marked this pull request as ready for review February 23, 2026 14:16
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

thanks!

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@TheBlueMatt TheBlueMatt merged commit eb3980d into lightningdevkit:main Feb 23, 2026
21 of 22 checks passed
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