diff options
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 0f453111c72..c79db622901 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -411,10 +411,21 @@ void MMapAllocator::free(PtrAndSize alloc) const { void MMapAllocator::sfree(PtrAndSize alloc) { if (alloc.first != nullptr) { - int retval = madvise(alloc.first, alloc.second, MADV_DONTNEED); - assert(retval == 0); - retval = munmap(alloc.first, alloc.second); - assert(retval == 0); + int madvise_retval = madvise(alloc.first, alloc.second, MADV_DONTNEED); + if (madvise_retval != 0) { + std::error_code ec(errno, std::system_category()); + if (errno == EINVAL) { + LOG(debug, "madvise(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, madvise_retval, ec.message().c_str()); + } else { + LOG(warning, "madvise(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, madvise_retval, ec.message().c_str()); + } + } + int munmap_retval = munmap(alloc.first, alloc.second); + if (munmap_retval != 0) { + std::error_code ec(errno, std::system_category()); + LOG(warning, "munmap(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, munmap_retval, ec.message().c_str()); + abort(); + } if (alloc.second >= _G_MMapLogLimit) { std::lock_guard guard(_G_lock); MMapInfo info = _G_HugeMappings[alloc.first]; |