[PATCH] D36231: [asan] Make dump_registers.cc more stable
Kuba (Brecka) Mracek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 2 10:35:22 PDT 2017
kubamracek created this revision.
kubamracek added a project: Sanitizers.
Repository:
rL LLVM
https://reviews.llvm.org/D36231
Files:
test/asan/TestCases/Darwin/dump_registers.cc
Index: test/asan/TestCases/Darwin/dump_registers.cc
===================================================================
--- test/asan/TestCases/Darwin/dump_registers.cc
+++ test/asan/TestCases/Darwin/dump_registers.cc
@@ -5,22 +5,22 @@
#include <assert.h>
#include <stdio.h>
+#include <sys/mman.h>
int main() {
fprintf(stderr, "Hello\n");
char *ptr;
- if (sizeof(void *) == 8)
- ptr = (char *)0x6666666666666666;
- else if (sizeof(void *) == 4)
- ptr = (char *)0x55555555;
- else
- assert(0 && "Your computer is weird.");
+ ptr = (char *)mmap(NULL, 0x10000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ assert(ptr && "failed to mmap");
+
+ fprintf(stderr, "p = 0x%08x\n", (uintptr_t)ptr);
+ // CHECK: p = [[ADDR:0x[0-9]+]]
char c = *ptr; // BOOM
// CHECK: ERROR: AddressSanitizer: {{SEGV|BUS}}
// CHECK: Register values:
- // CHECK: {{0x55555555|0x6666666666666666}}
+ // CHECK: [[ADDR]]
fprintf(stderr, "World\n");
return c;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36231.109375.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/9e1000b7/attachment.bin>
More information about the llvm-commits
mailing list