Bugfix: AllocateFileRange: Address various issues #33228

pull luke-jr wants to merge 5 commits into bitcoin:master from luke-jr:fix_preallocate changing 1 files +23 −8
  1. luke-jr commented at 3:35 pm on August 20, 2025: member

    Fixes several bugs in AllocateFileRange.

    Not a real fix for #33128, but a workaround for the issue.

    Potentially might fix #28552 too, but I don’t have a way to reproduce that. (After digging into Apple’s XNU code, it looks too buggy to try to use F_PREALLOCATE at all IMO; for reference: XNU kernel code and HFS driver code - notice the truncation risk from comparing to block-allocated size rather than file size and reachable code paths the comments assume to be dead code)

  2. Bugfix: AllocateFileRange: Disable buggy macOS-specific implementation
    Several bugs exist:
    - F_PREALLOCATE is undone at close (which we do immediately)
    - HFS implementation appears buggy (and we have unknown issues on macOS with exFAT - possibly related?)
    - F_PEOFPOSMODE assumes offset is EOF exactly
    cab5e8d861
  3. Bugfix: AllocateFileRange: Only posix_fallocate the intended range 4a9f8c78f6
  4. Bugfix: AllocateFileRange: Don't SetEndOfFile if SetFilePointerEx fails 8e9c114fae
  5. AllocateFileRange: Avoid clobbering data in fallback implementation
    While this data should never be live, in practice it can be right now, so better play it safe
    476861713e
  6. Bugfix: AllocateFileRange: Avoid truncating files on Windows 2c113ebc2d
  7. DrahtBot commented at 3:35 pm on August 20, 2025: contributor

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

    Code Coverage & Benchmarks

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

    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:

    • #33164 (Avoid file overwriting in fallback AllocateFileRange implementation by hebasto)
    • #32645 (fs: use ftruncate in AllocateFileRange on OpenBSD by theStack)

    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.


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: 2025-09-02 12:13 UTC

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