fuzz: target CDBWrapper #34887

pull andrewtoth wants to merge 3 commits into bitcoin:master from andrewtoth:fuzz-dbwrapper changing 5 files +290 −2
  1. andrewtoth commented at 1:12 am on March 21, 2026: contributor

    Inspired by #34866 (comment).

    We currently don’t have a dedicated harness targeting CDBWrapper. OSS-Fuzz has a rudimentary harness for levelDB which fails, so doesn’t appear maintained.

    This PR adds a harness targeting CDBWrapper against an in-memory oracle to verify correctness.

    A DeterministicEnv wraps levelDB’s memenv to eliminate non-determinism by capturing background compaction and running it at fuzzer-chosen points. The fuzzer also controls the cache_bytes and max_file_size sizes so that small values trigger memtable flushes and compaction.

  2. DrahtBot added the label Fuzzing on Mar 21, 2026
  3. DrahtBot commented at 1:12 am on March 21, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK marcofleon

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    No conflicts as of last run.

  4. DrahtBot added the label CI failed on Mar 21, 2026
  5. andrewtoth force-pushed on Mar 21, 2026
  6. DrahtBot removed the label CI failed on Mar 21, 2026
  7. andrewtoth force-pushed on Mar 21, 2026
  8. andrewtoth force-pushed on Mar 21, 2026
  9. andrewtoth force-pushed on Mar 21, 2026
  10. DrahtBot added the label CI failed on Mar 22, 2026
  11. andrewtoth force-pushed on Mar 22, 2026
  12. andrewtoth force-pushed on Mar 22, 2026
  13. DrahtBot removed the label CI failed on Mar 22, 2026
  14. dbwrapper: make max_file_size a configurable DBParams field
    Useful for fuzzing different values.
    9e444624bb
  15. dbwrapper: accept optional testing leveldb::Env in DBParams
    Allow callers to inject a custom leveldb::Env via DBParams::testing_env,
    which takes priority over the memory_only in-memory environment. This
    enables fuzz harnesses to supply a deterministic environment.
    e903203536
  16. andrewtoth force-pushed on Mar 29, 2026
  17. marcofleon commented at 3:22 pm on April 2, 2026: contributor

    Concept ACK

    Nice differential fuzz test. I’m running it now and I’ll do a more thorough review soon.

  18. test: add fuzz harness for CDBWrapper
    Introduces a libFuzzer harness that exercises CDBWrapper operations
    against a std::map oracle, with a DeterministicEnv that captures LevelDB
    background compaction for single-threaded determinism.
    b967e255e7
  19. andrewtoth force-pushed on Apr 11, 2026
  20. andrewtoth commented at 3:10 pm on April 11, 2026: contributor

    Improved the assertions around iterators. This now exhausts the DB iterator completely instead of using LIMITED_WHILE, and asserts that the oracle iterator is also exhausted, ensuring no entries are missing.

    Also added coverage for failing to deserialize a value by reading with a type that always throws on deserialization.

    git diff 430f357f7e304336d2b61f72d2bc5439dea557d8..b967e255e7620b8366ec1aeb8932138455be8701


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-12 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me