fix(windows): pair aligned delete with its allocator - #2281
knewstimek wants to merge 1 commit into
Conversation
Signed-off-by: News <knewstimek@users.noreply.github.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
DeusData
left a comment
There was a problem hiding this comment.
Thank you for chasing this after #2260. A fault inside _aligned_free is the kind of crash that is hard to pin down, and your explanation of the deallocator mismatch is clear.
I tried to reproduce it on our Windows ARM64 VM (MSYS2 CLANGARM64, lld) before merging, and found something I'd like to check with you:
- A production build of main (
CBM_MEM_GLOBAL_OVERRIDE=1) indexed a 1,572-file C/C++ tree with parallel workers without a fault. - In that binary,
operator delete(void*, std::align_val_t)loads its target from__imp___wrap__aligned_free. That pointer leads to our__wrap__aligned_free, not UCRT's_aligned_free. The other five aligned delete entry points tail-call into it. So on this toolchain lld already rewrites the__imp__aligned_freereference, which is the reference the PR says--wrapmisses.
That makes me think the difference is in the toolchain. Could you share:
- the toolchain and linker you built with (LLVM-MinGW release or MSYS2 CLANG64, and its version, x64 I assume),
- the crash stack, or at least the frame that called
_aligned_free, - if you can, a public C++ project that reproduces it.
The first hunk, which sends a CRT-owned aligned block to __real__aligned_free instead of __real_free, is correct on its own: _aligned_free is the matching deallocator. We are happy to take that part as it is. For the six operator delete definitions, we'd like to know which toolchain needs them. If the release toolchain doesn't need them, they would silently replace libc++abi's own definitions for no benefit. A comment naming the toolchain that does need them would also help the next reader.
Thank you again for the careful work on the Windows allocator path.
Fix aligned C++ delete on Windows with the global mimalloc override.
LLVM-MinGW's C++ runtime can call the CRT import pointer
__imp__aligned_freedirectly. The linker's--wrap=_aligned_freedoes not catch that call, so aligned allocation from mimalloc can reach UCRT's deallocator. The six aligned delete ABI entry points now use the owner-aware wrapper. CRT-owned aligned blocks still go through__real__aligned_freebecause they carry a CRT header.This follows #2260, which changed aligned allocation. A production-flag Windows build previously faulted in
_aligned_freewhile indexing a multi-file C++ project with parallel workers; the same index completed with this fix. The project had multiple translation units and aligned C++ allocations. The unit-test build does not enableCBM_MEM_GLOBAL_OVERRIDE, so it cannot exercise this path; the Windows productionpr-smokebuild is the relevant CI leg.Split from #2268. No encoding or compile database changes.