From 84ae6bfd6f61775b9e20742cdc5bc73ecd0829c3 Mon Sep 17 00:00:00 2001 From: willsfeng Date: Sat, 6 Apr 2024 00:07:54 -0700 Subject: [PATCH] Handling MAP_FAILED in MmapAllocator (#9228) Summary: This PR is addressing this issue https://github.com/facebookincubator/velox/issues/9135 Pull Request resolved: https://github.com/facebookincubator/velox/pull/9228 Reviewed By: Yuhta Differential Revision: D55609322 Pulled By: xiaoxmeng fbshipit-source-id: c1921fd5551c553384fde4ffddf80ad659471094 --- velox/common/memory/MmapAllocator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/velox/common/memory/MmapAllocator.cpp b/velox/common/memory/MmapAllocator.cpp index 11f6c86fa0d4..2383b33698ea 100644 --- a/velox/common/memory/MmapAllocator.cpp +++ b/velox/common/memory/MmapAllocator.cpp @@ -336,12 +336,12 @@ bool MmapAllocator::allocateContiguousImpl( 0); } } - // TODO: add handling of MAP_FAILED. - if (data == nullptr) { + if (data == nullptr || data == MAP_FAILED) { const std::string errorMsg = fmt::format( - "Mmap failed with {} pages use MmapArena {}", + "Mmap failed with {} pages use MmapArena {}, errno {}", numPages, - (useMmapArena_ ? "true" : "false")); + (useMmapArena_ ? "true" : "false"), + folly::errnoStr(errno)); VELOX_MEM_LOG(ERROR) << errorMsg; setAllocatorFailureMessage(errorMsg); // If the mmap failed, we have unmapped former 'allocation' and the extra to