diff --git a/utils/logalloc.cc b/utils/logalloc.cc index 728d67356f..7ffaa55758 100644 --- a/utils/logalloc.cc +++ b/utils/logalloc.cc @@ -667,6 +667,7 @@ segment* segment_pool::allocate_segment(size_t reserve, size_t reclamation_step) return seg; } if (can_allocate_more_memory(segment::size)) { + memory::disable_abort_on_alloc_failure_temporarily dfg; auto p = aligned_alloc(segment::size, segment::size); if (!p) { continue; @@ -677,10 +678,6 @@ segment* segment_pool::allocate_segment(size_t reserve, size_t reclamation_step) return seg; } } while (shard_tracker().get_impl().compact_and_evict(reclamation_step * segment::size)); - if (shard_tracker().should_abort_on_bad_alloc()) { - llogger.error("Aborting due to segment allocation failure"); - abort(); - } return nullptr; } @@ -2286,7 +2283,15 @@ void allocating_section::on_alloc_failure(logalloc::region& r) { _std_reserve *= 2; // FIXME: decay? llogger.debug("Standard allocator failure, increasing head-room in section {} to {} [B]", this, _std_reserve); } - reserve(); + try { + reserve(); + } catch (const std::bad_alloc&) { + if (shard_tracker().should_abort_on_bad_alloc()) { + llogger.error("Aborting due to allocation failure"); + abort(); + } + throw; + } } #else diff --git a/utils/logalloc.hh b/utils/logalloc.hh index 43261d941b..58c253266d 100644 --- a/utils/logalloc.hh +++ b/utils/logalloc.hh @@ -710,6 +710,7 @@ public: while (true) { try { logalloc::reclaim_lock _(r); + memory::disable_abort_on_alloc_failure_temporarily dfg; return fn(); } catch (const std::bad_alloc&) { on_alloc_failure(r);