Skip to content

fuzz: target CDBWrapper#34887

Open
andrewtoth wants to merge 3 commits intobitcoin:masterfrom
andrewtoth:fuzz-dbwrapper
Open

fuzz: target CDBWrapper#34887
andrewtoth wants to merge 3 commits intobitcoin:masterfrom
andrewtoth:fuzz-dbwrapper

Conversation

@andrewtoth
Copy link
Contributor

@andrewtoth andrewtoth commented Mar 21, 2026

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 21, 2026

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

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34866 (fuzz: target concurrent leveldb reads by andrewtoth)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants