aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/blob.cpp
diff options
context:
space:
mode:
authorponasenko-rs <ponasenko-rs@yandex-team.com>2025-02-05 13:51:25 +0300
committerponasenko-rs <ponasenko-rs@yandex-team.com>2025-02-05 14:12:49 +0300
commit2433515f1c61fb702b8316e097280e6e4bf8b210 (patch)
treeb52f21c64341e920743b0310bb256a33000e1ea9 /library/cpp/yt/memory/blob.cpp
parent6637a125e91f1c5fc82dfd3b05b5153a850a1b21 (diff)
downloadydb-2433515f1c61fb702b8316e097280e6e4bf8b210.tar.gz
YT-24135: Check for oom in TBlob::DoAllocate
commit_hash:51660c0e427c358c8285a5889c7dd585a97e5140
Diffstat (limited to 'library/cpp/yt/memory/blob.cpp')
-rw-r--r--library/cpp/yt/memory/blob.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/library/cpp/yt/memory/blob.cpp b/library/cpp/yt/memory/blob.cpp
index b4de038948..2517446ec7 100644
--- a/library/cpp/yt/memory/blob.cpp
+++ b/library/cpp/yt/memory/blob.cpp
@@ -4,6 +4,8 @@
#include <library/cpp/yt/malloc/malloc.h>
+#include <library/cpp/yt/system/exit.h>
+
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
@@ -147,9 +149,17 @@ void TBlob::Reset()
char* TBlob::DoAllocate(size_t size)
{
- return static_cast<char*>(PageAligned_
+ auto* allocated = static_cast<char*>(PageAligned_
? ::aligned_malloc(size, GetPageSize())
: ::malloc(size));
+
+ if (Y_UNLIKELY(!allocated)) {
+ AbortProcessDramatically(
+ EProcessExitCode::OutOfMemory,
+ "Out-of-memory during TBlob allocation");
+ }
+
+ return allocated;
}
void TBlob::Allocate(size_t newCapacity)