fuzz: fix dead HD keypaths (de)serialization round-trip #35481

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202606-fuzz-fix-deserializehdkeypaths_roundtrip changing 1 files +1 −1
  1. theStack commented at 7:02 PM on June 7, 2026: contributor

    DeserializeHDKeypaths() was writing into the original hd_keypaths map instead of deserialized_hd_keypaths. As a result the latter was always empty and the round-trip assertion following was trivially true, so the serialize/deserialize round-trip wasn't actually being exercised.

    That bug was introduced with the commit introducing the fuzz target (commit f898ef65c947776750e49d050633f830546bbdc6, #18994).

  2. fuzz: fix dead HD keypaths (de)serialization round-trip
    `DeserializeHDKeypaths()` was writing into the original `hd_keypaths`
    map instead of `deserialized_hd_keypaths`. As a result the latter was
    always empty and the round-trip assertion following was trivially true,
    so the serialize/deserialize round-trip wasn't actually being exercised.
    
    That bug was introduced with the commit introducing the fuzz target
    (commit f898ef65c947776750e49d050633f830546bbdc6, #18994).
    5deb053a75
  3. DrahtBot added the label Fuzzing on Jun 7, 2026
  4. DrahtBot commented at 7:02 PM on June 7, 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/35481.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. sedited approved
  6. sedited commented at 8:05 PM on June 7, 2026: contributor

    ACK 5deb053a75fb0529618a2980d9b6a6ba9928d039

  7. sedited merged this on Jun 7, 2026
  8. sedited closed this on Jun 7, 2026

  9. theStack deleted the branch on Jun 7, 2026
  10. in src/test/fuzz/script_sign.cpp:71 in 5deb053a75
      66 | @@ -67,7 +67,7 @@ FUZZ_TARGET(script_sign, .init = initialize_script_sign)
      67 |          }
      68 |          std::map<CPubKey, KeyOriginInfo> deserialized_hd_keypaths;
      69 |          try {
      70 | -            DeserializeHDKeypaths(serialized, key, hd_keypaths);
      71 | +            DeserializeHDKeypaths(serialized, key, deserialized_hd_keypaths);
      72 |          } catch (const std::ios_base::failure&) {
    


    l0rinc commented at 8:57 PM on June 7, 2026:

    do we still need the try/catch? Doesn't that kinda' defeat the purpose of a fuzzer?


    sedited commented at 9:04 PM on June 7, 2026:

    afaict the key can still have a bad size here, which triggers a try/catch, no?


    l0rinc commented at 9:16 PM on June 7, 2026:

    shouldn't we guard for that specifically and abort in other cases? Otherwise what's the point of this call, to have fake coverage?


    sedited commented at 7:46 AM on June 8, 2026:

    This is how we handle stream and serialization failures in all the fuzz tests. I think that is fine to be honest. Code calling this function has to handle this exception in the same manner with the highest-level exception type. We could match on the various debug strings for them, but I'm not sure if we really gain much soundness from that.


    l0rinc commented at 10:45 AM on June 8, 2026:

    What do we gain from calling it as such (besides fake code coverage), i.e. calling the method and silencing every potentially useful outcome?

    I understand the cases when a generator method throws - but it should terminate execution if it wasn't able to create a new useful value, e.g.: https://github.com/bitcoin/bitcoin/blob/c01c7f068c5b67329794bac9354eb112111815ee/src/test/fuzz/rpc.cpp#L54-L58

    In other cases we're validating the failure reason, e.g. https://github.com/bitcoin/bitcoin/blob/c01c7f068c5b67329794bac9354eb112111815ee/src/test/fuzz/rpc.cpp#L389-L403


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-06-11 10:51 UTC

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