fuzz: target concurrent leveldb reads #34866

pull andrewtoth wants to merge 1 commits into bitcoin:master from andrewtoth:fuzz_db_reads changing 2 files +124 −0
  1. andrewtoth commented at 1:41 pm on March 19, 2026: contributor

    Inspired by #31132 (comment).

    We currently do concurrent leveldb reads when accessing our indexes.

    1. txindex - we call FindTx() from multiple RPC threads.
    2. blockfilterindex - we call LookupFilter/Header() concurrently from msghand thread for p2p requests as well as RPC threads.
    3. coinstatsindex - we call LookUpStats() from multiple RPC threads.
    4. txospenderindex - we call FindSpender() from multiple RPC threads.

    We also read from our chainstate and blocks index while background compactions are writing.

    While OSS-Fuzz does cover leveldb (https://github.com/google/oss-fuzz/blob/master/projects/leveldb/fuzz_db.cc), it doesn’t cover multi threaded access. Without a deterministic hypervisor this fuzz harness won’t be deterministic, but we can at least run it with TSan to get a higher confidence that the synchronization code in leveldb is correct. Hopefully other reviewers find this useful.

    This harness creates a global threadpool with 32 threads and in-memory levelDB, which it seeds with 10k random values. It selects up to 32 threads and chooses a random set of keys to query. It first performs all queries on the db on a single thread to get a baseline, then synchronizes all threads on a latch so they hit the db at the same time. Each thread performs the same queries, and afterwards are all checked against the baseline. Optionally, at the start of each iteration, the fuzzer can overwrite 2k entries to trigger a memtable flush and potentially a background compaction.

    I ran both TSan and ASan/UBSan overnight with no issues.

  2. fuzz: target concurrent leveldb reads 402785d0e3
  3. DrahtBot added the label Fuzzing on Mar 19, 2026
  4. DrahtBot commented at 1:41 pm on March 19, 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. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34887 (fuzz: target CDBWrapper 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.

  5. maflcko commented at 1:52 pm on March 19, 2026: member

    While OSS-Fuzz does cover leveldb (https://github.com/google/oss-fuzz/blob/master/projects/leveldb/fuzz_db.cc), it …

    I wouldn’t put too much value in this. I think there is only a single fuzz target, which fails, according to https://issues.oss-fuzz.com/issues/447252244, so it may be unmaintained.


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-03-23 09:13 UTC

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