[llvm] Work around documented Linux mmap bug. (PR #152595)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 10:44:33 PDT 2025
================
@@ -501,8 +501,15 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
std::unique_ptr<MB> Result(
new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile<MB>(
RequiresNullTerminator, FD, MapSize, Offset, EC));
- if (!EC)
- return std::move(Result);
+ if (!EC) {
+#ifdef __linux__
----------------
efriedma-quic wrote:
How sure are we that Linux is the only OS which has this issue? Would it make sense to just remove the ifdef?
There's also a race condition here: if another processes modifies the file while it's mapped, you get undefined behavior. But we can't really do much about that.
https://github.com/llvm/llvm-project/pull/152595
More information about the llvm-commits
mailing list