fuzz: reset chainman after external block imports #36129

pull HowHsu wants to merge 1 commits into bitcoin:master from HowHsu:fuzz-reset-load-external-chainman changing 1 files +23 −2
  1. HowHsu commented at 1:45 PM on August 31, 2026: contributor

    LoadExternalBlockFile() may add headers to the block index even when full block validation fails. Reusing the static chainman therefore lets one fuzz input affect later inputs and makes all-corpus coverage order-dependent.

    Recreate the chainman after each processed input, disable unused network setup so PeerManager cannot retain a reference to it, and reseed the deterministic test RNG consumed by chainman initialization.

    Tested with run_deterministic_fuzz_coverage.sh load_external_block_file 20: all 930 corpus inputs passed both the individual-repeat and randomized all-corpus checks.

  2. DrahtBot added the label Fuzzing on Aug 31, 2026
  3. DrahtBot commented at 1:45 PM on August 31, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36129.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. fuzz: reset chainman after external block imports
    LoadExternalBlockFile may add headers to the block index even when
    full block validation fails. Reusing the static chainman lets one fuzz
    input affect later inputs and makes shuffled corpus coverage
    order-dependent.
    eb3c6f296d
  5. in src/test/fuzz/load_external_block_file.cpp:56 in 0243779e73
      48 | @@ -44,4 +49,9 @@ FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_fil
      49 |          // Corresponds to the -loadblock= case (orphan blocks aren't tracked across files).
      50 |          g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file);
      51 |      }
      52 | +
      53 | +    // Prevent block index state from leaking into the next fuzz input.
      54 | +    g_setup->m_node.chainman.reset();
      55 | +    g_setup->m_make_chainman();
      56 | +    g_setup->LoadVerifyActivateChainstate();
    


    maflcko commented at 7:22 AM on September 1, 2026:

    Will it be faster if there is a dirty-guard to only run this when needed?


    HowHsu commented at 9:30 AM on September 3, 2026:

    Will it be faster if there is a dirty-guard to only run this when needed?

    Yes, but seems only check the index size change is not enough, at least the change of m_last_notified_header depends on the input order, there could be other variables at play. How about make this unconditional reset version as our first step?

  6. HowHsu force-pushed on Sep 3, 2026
Labels

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-09-09 07:56 UTC