[DFSan] [compiler-rt] leave BufferedStackTrace uninit

Otherwise we have to memset 2040 bytes (255 * 8) for each call

Pull Request: https://github.com/llvm/llvm-project/pull/102252
This commit is contained in:
Florian Mayer
2024-08-06 16:47:39 -07:00
parent e4104c0eea
commit 4cad17de79
3 changed files with 12 additions and 12 deletions

View File

@@ -195,7 +195,7 @@ static dfsan_origin GetOriginIfTainted(uptr addr, uptr size) {
// random freezes in forking applications as well as in signal handlers.
// DFSan supports only Linux. So we do not restrict the store context size.
#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
BufferedStackTrace stack; \
UNINITIALIZED BufferedStackTrace stack; \
stack.Unwind(pc, bp, nullptr, true, flags().store_context_size);
#define PRINT_CALLER_STACK_TRACE \

View File

@@ -95,13 +95,13 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
size);
return nullptr;
}
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportAllocationSizeTooBig(size, max_malloc_size, &stack);
}
if (UNLIKELY(IsRssLimitExceeded())) {
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportRssLimitExceeded(&stack);
}
DFsanThread *t = GetCurrentThread();
@@ -118,7 +118,7 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
SetAllocatorOutOfMemory();
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportOutOfMemory(size, &stack);
}
Metadata *meta =
@@ -175,7 +175,7 @@ void *DFsanCalloc(uptr nmemb, uptr size) {
if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) {
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportCallocOverflow(nmemb, size, &stack);
}
return DFsanAllocate(nmemb * size, sizeof(u64), true /*zeroise*/);
@@ -232,7 +232,7 @@ void *dfsan_reallocarray(void *ptr, uptr nmemb, uptr size) {
errno = errno_ENOMEM;
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportReallocArrayOverflow(nmemb, size, &stack);
}
return dfsan_realloc(ptr, nmemb * size);
@@ -249,7 +249,7 @@ void *dfsan_pvalloc(uptr size) {
errno = errno_ENOMEM;
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportPvallocOverflow(size, &stack);
}
// pvalloc(0) should allocate one page.
@@ -262,7 +262,7 @@ void *dfsan_aligned_alloc(uptr alignment, uptr size) {
errno = errno_EINVAL;
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportInvalidAlignedAllocAlignment(size, alignment, &stack);
}
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -273,7 +273,7 @@ void *dfsan_memalign(uptr alignment, uptr size) {
errno = errno_EINVAL;
if (AllocatorMayReturnNull())
return nullptr;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportInvalidAllocationAlignment(alignment, &stack);
}
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -283,7 +283,7 @@ int dfsan_posix_memalign(void **memptr, uptr alignment, uptr size) {
if (UNLIKELY(!CheckPosixMemalignAlignment(alignment))) {
if (AllocatorMayReturnNull())
return errno_EINVAL;
BufferedStackTrace stack;
UNINITIALIZED BufferedStackTrace stack;
ReportInvalidPosixMemalignAlignment(alignment, &stack);
}
void *ptr = DFsanAllocate(size, alignment, false /*zeroise*/);

View File

@@ -30,14 +30,14 @@ enum class align_val_t : size_t {};
#define OPERATOR_NEW_BODY(nothrow) \
void *res = dfsan_malloc(size); \
if (!nothrow && UNLIKELY(!res)) { \
BufferedStackTrace stack; \
UNINITIALIZED BufferedStackTrace stack; \
ReportOutOfMemory(size, &stack); \
} \
return res
#define OPERATOR_NEW_BODY_ALIGN(nothrow) \
void *res = dfsan_memalign((uptr)align, size); \
if (!nothrow && UNLIKELY(!res)) { \
BufferedStackTrace stack; \
UNINITIALIZED BufferedStackTrace stack; \
ReportOutOfMemory(size, &stack); \
} \
return res;