fuzz: refactor memcpy to std::ranges::copy to work around ubsan warn #33743

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2510-fuzz-refactor-memcpy changing 1 files +6 −5
  1. maflcko commented at 10:10 AM on October 30, 2025: member

    Using std::ranges::copy from the C++ standard library has a few benefits here:

    • It has the additional benefit of being a bit more type safe and document the byte cast explicitly.
    • The compiler will likely optimize it to the same asm, but performance doesn't really matter here anyway.
    • It has defined semantics for empty source ranges.

    Fixes https://github.com/bitcoin/bitcoin/issues/33643

  2. fuzz: refactor memcpy to std::ranges::copy to work around ubsan warn
    Using std::ranges::copy from the C++ standard library has a few benefits
    here:
    
    * It has the additional benefit of being a bit more type safe and
      document the byte cast explicitly.
    * The compiler will likely optimize it to the same asm, but performance
      doesn't really matter here anyway.
    * It works around an UB-Sanitizer bug, when the source range is empty.
    
    Fixes https://github.com/bitcoin/bitcoin/issues/33643
    fa4b52bd16
  3. DrahtBot added the label Tests on Oct 30, 2025
  4. DrahtBot commented at 10:10 AM on October 30, 2025: 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/33743.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK marcofleon, dergoegge

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. maflcko added this to the milestone 31.0 on Oct 30, 2025
  6. fanquake commented at 10:11 AM on October 30, 2025: member
  7. maflcko force-pushed on Oct 30, 2025
  8. purpleKarrot commented at 1:30 PM on October 30, 2025: contributor
    • It works around an UB-Sanitizer bug, when the source range is empty.

    I guess what you want to express is:

    • It has defined semantics for empty source ranges.

    Passing a zero length to memcpy is UB per the language standard. This is not an "UB-Sanitizer bug".

  9. fanquake added the label Fuzzing on Oct 30, 2025
  10. maflcko commented at 2:18 PM on October 30, 2025: member

    Yeah, I guess it is too early to call this a bug, but the language standard has been changed, see #33644 (comment).

    I've used your wording for now.

  11. marcofleon commented at 3:01 PM on October 30, 2025: contributor

    tACK fa4b52bd16189d40761c5976b8427e30779aba23

    Tested this branch and didn't see the null pointer error. The change to std::byte is for modernization and the change to std::ranges addresses the issue.

  12. dergoegge approved
  13. dergoegge commented at 9:54 AM on October 31, 2025: member

    utACK fa4b52bd16189d40761c5976b8427e30779aba23

  14. fanquake merged this on Oct 31, 2025
  15. fanquake closed this on Oct 31, 2025

  16. maflcko deleted the branch on Oct 31, 2025
  17. sedited referenced this in commit c4d4877626 on Nov 5, 2025
  18. stickies-v referenced this in commit a785fe6759 on Nov 5, 2025
  19. stringintech referenced this in commit b82132c4d1 on Nov 6, 2025
  20. yuvicc referenced this in commit f620a2206b on Nov 16, 2025
  21. Kino1994 referenced this in commit 372ff73db9 on Jun 28, 2026
  22. BigcoinBGC referenced this in commit 717b3adfa1 on Jun 30, 2026
  23. Kino1994 referenced this in commit 78ffb55e73 on Aug 19, 2026
  24. bitcoin locked this on Oct 31, 2026

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-11-18 16:51 UTC

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