util: diagnose dangling views of temporary strings #36164

pull l0rinc wants to merge 2 commits into bitcoin:master from l0rinc:l0rinc/diagnose-dangling-string-views changing 1 files +6 −6
  1. l0rinc commented at 2:00 AM on September 4, 2026: contributor

    Problem: Several string utilities return or store views into their input. A temporary std::string can leave these views dangling, although no current caller does this.

    Fix: Add LIFETIMEBOUND so Clang diagnoses the misuse while preserving immediate use. Pass the Split span by value so lvalue strings do not trigger false warnings.

  2. util: annotate string view input lifetimes
    The string-view helpers return views into their input, while `LineReader` stores one.
    Annotate their inputs so Clang can warn when a returned or stored view outlives a temporary string.
    34c5dc0583
  3. util: annotate `Split` input lifetime
    `Split` can return views into its input, but annotating its old reference warns for lvalue strings.
    Take the span by value so Clang follows the backing storage.
    
    `Split<std::string>` copies results but can still warn, while `SplitString` is unaffected.
    b57b0dbebd
  4. DrahtBot added the label Utils/log/libs on Sep 4, 2026
  5. DrahtBot commented at 2:00 AM on September 4, 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/36164.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors

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-04 07:51 UTC

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