Skip to content

Commit 4cad17d

Browse files
committed
[DFSan] [compiler-rt] leave BufferedStackTrace uninit
Otherwise we have to memset 2040 bytes (255 * 8) for each call Pull Request: #102252
1 parent e4104c0 commit 4cad17d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

compiler-rt/lib/dfsan/dfsan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static dfsan_origin GetOriginIfTainted(uptr addr, uptr size) {
195195
// random freezes in forking applications as well as in signal handlers.
196196
// DFSan supports only Linux. So we do not restrict the store context size.
197197
#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
198-
BufferedStackTrace stack; \
198+
UNINITIALIZED BufferedStackTrace stack; \
199199
stack.Unwind(pc, bp, nullptr, true, flags().store_context_size);
200200

201201
#define PRINT_CALLER_STACK_TRACE \

compiler-rt/lib/dfsan/dfsan_allocator.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
9595
size);
9696
return nullptr;
9797
}
98-
BufferedStackTrace stack;
98+
UNINITIALIZED BufferedStackTrace stack;
9999
ReportAllocationSizeTooBig(size, max_malloc_size, &stack);
100100
}
101101
if (UNLIKELY(IsRssLimitExceeded())) {
102102
if (AllocatorMayReturnNull())
103103
return nullptr;
104-
BufferedStackTrace stack;
104+
UNINITIALIZED BufferedStackTrace stack;
105105
ReportRssLimitExceeded(&stack);
106106
}
107107
DFsanThread *t = GetCurrentThread();
@@ -118,7 +118,7 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
118118
SetAllocatorOutOfMemory();
119119
if (AllocatorMayReturnNull())
120120
return nullptr;
121-
BufferedStackTrace stack;
121+
UNINITIALIZED BufferedStackTrace stack;
122122
ReportOutOfMemory(size, &stack);
123123
}
124124
Metadata *meta =
@@ -175,7 +175,7 @@ void *DFsanCalloc(uptr nmemb, uptr size) {
175175
if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) {
176176
if (AllocatorMayReturnNull())
177177
return nullptr;
178-
BufferedStackTrace stack;
178+
UNINITIALIZED BufferedStackTrace stack;
179179
ReportCallocOverflow(nmemb, size, &stack);
180180
}
181181
return DFsanAllocate(nmemb * size, sizeof(u64), true /*zeroise*/);
@@ -232,7 +232,7 @@ void *dfsan_reallocarray(void *ptr, uptr nmemb, uptr size) {
232232
errno = errno_ENOMEM;
233233
if (AllocatorMayReturnNull())
234234
return nullptr;
235-
BufferedStackTrace stack;
235+
UNINITIALIZED BufferedStackTrace stack;
236236
ReportReallocArrayOverflow(nmemb, size, &stack);
237237
}
238238
return dfsan_realloc(ptr, nmemb * size);
@@ -249,7 +249,7 @@ void *dfsan_pvalloc(uptr size) {
249249
errno = errno_ENOMEM;
250250
if (AllocatorMayReturnNull())
251251
return nullptr;
252-
BufferedStackTrace stack;
252+
UNINITIALIZED BufferedStackTrace stack;
253253
ReportPvallocOverflow(size, &stack);
254254
}
255255
// pvalloc(0) should allocate one page.
@@ -262,7 +262,7 @@ void *dfsan_aligned_alloc(uptr alignment, uptr size) {
262262
errno = errno_EINVAL;
263263
if (AllocatorMayReturnNull())
264264
return nullptr;
265-
BufferedStackTrace stack;
265+
UNINITIALIZED BufferedStackTrace stack;
266266
ReportInvalidAlignedAllocAlignment(size, alignment, &stack);
267267
}
268268
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -273,7 +273,7 @@ void *dfsan_memalign(uptr alignment, uptr size) {
273273
errno = errno_EINVAL;
274274
if (AllocatorMayReturnNull())
275275
return nullptr;
276-
BufferedStackTrace stack;
276+
UNINITIALIZED BufferedStackTrace stack;
277277
ReportInvalidAllocationAlignment(alignment, &stack);
278278
}
279279
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -283,7 +283,7 @@ int dfsan_posix_memalign(void **memptr, uptr alignment, uptr size) {
283283
if (UNLIKELY(!CheckPosixMemalignAlignment(alignment))) {
284284
if (AllocatorMayReturnNull())
285285
return errno_EINVAL;
286-
BufferedStackTrace stack;
286+
UNINITIALIZED BufferedStackTrace stack;
287287
ReportInvalidPosixMemalignAlignment(alignment, &stack);
288288
}
289289
void *ptr = DFsanAllocate(size, alignment, false /*zeroise*/);

compiler-rt/lib/dfsan/dfsan_new_delete.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ enum class align_val_t : size_t {};
3030
#define OPERATOR_NEW_BODY(nothrow) \
3131
void *res = dfsan_malloc(size); \
3232
if (!nothrow && UNLIKELY(!res)) { \
33-
BufferedStackTrace stack; \
33+
UNINITIALIZED BufferedStackTrace stack; \
3434
ReportOutOfMemory(size, &stack); \
3535
} \
3636
return res
3737
#define OPERATOR_NEW_BODY_ALIGN(nothrow) \
3838
void *res = dfsan_memalign((uptr)align, size); \
3939
if (!nothrow && UNLIKELY(!res)) { \
40-
BufferedStackTrace stack; \
40+
UNINITIALIZED BufferedStackTrace stack; \
4141
ReportOutOfMemory(size, &stack); \
4242
} \
4343
return res;

0 commit comments

Comments
 (0)