Skip to content

Commit 1e40681

Browse files
authored
Revert "[msan] Detect dereferencing zero-alloc as use-of-uninitialized-value …"
This reverts commit 8784dce.
1 parent e68d66a commit 1e40681

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

compiler-rt/lib/msan/msan_allocator.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,6 @@ static void *MsanAllocate(BufferedStackTrace *stack, uptr size, uptr alignment,
230230
__msan_set_origin(allocated, size, o.raw_id());
231231
}
232232
}
233-
234-
uptr actually_allocated_size = allocator.GetActuallyAllocatedSize(allocated);
235-
// For compatibility, the allocator converted 0-sized allocations into 1 byte
236-
if (size == 0 && actually_allocated_size > 0 && flags()->poison_in_malloc)
237-
__msan_poison(allocated, 1);
238-
239233
UnpoisonParam(2);
240234
RunMallocHooks(allocated, size);
241235
return allocated;

compiler-rt/test/msan/zero_alloc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: %clang_msan -Wno-alloc-size -fsanitize-recover=memory %s -o %t && not %run %t 2>&1 | FileCheck %s
22

3+
// MSan doesn't catch this because internally it translates 0-byte allocations
4+
// into 1-byte
5+
// XFAIL: *
6+
37
#include <malloc.h>
48
#include <stdio.h>
59

0 commit comments

Comments
 (0)