aboutsummaryrefslogtreecommitdiff
path: root/lib/asan/tests/asan_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asan/tests/asan_test.cc')
-rw-r--r--lib/asan/tests/asan_test.cc32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc
index 952b05e21fe2..07d59e09a72f 100644
--- a/lib/asan/tests/asan_test.cc
+++ b/lib/asan/tests/asan_test.cc
@@ -31,13 +31,13 @@ NOINLINE void free_aaa(void *p) { free_bbb(p); break_optimization(0);}
template<typename T>
NOINLINE void uaf_test(int size, int off) {
- char *p = (char *)malloc_aaa(size);
+ void *p = malloc_aaa(size);
free_aaa(p);
for (int i = 1; i < 100; i++)
free_aaa(malloc_aaa(i));
fprintf(stderr, "writing %ld byte(s) at %p with offset %d\n",
(long)sizeof(T), p, off);
- asan_write((T*)(p + off));
+ asan_write((T *)((char *)p + off));
}
TEST(AddressSanitizer, HasFeatureAddressSanitizerTest) {
@@ -436,10 +436,10 @@ TEST(AddressSanitizer, WrongFreeTest) {
void DoubleFree() {
int *x = (int*)malloc(100 * sizeof(int));
- fprintf(stderr, "DoubleFree: x=%p\n", x);
+ fprintf(stderr, "DoubleFree: x=%p\n", (void *)x);
free(x);
free(x);
- fprintf(stderr, "should have failed in the second free(%p)\n", x);
+ fprintf(stderr, "should have failed in the second free(%p)\n", (void *)x);
abort();
}
@@ -569,7 +569,7 @@ TEST(AddressSanitizer, LongJmpTest) {
}
#if !defined(_WIN32) // Only basic longjmp is available on Windows.
-NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) {
+NOINLINE void UnderscopeLongJmpFunc1(jmp_buf buf) {
// create three red zones for these two stack objects.
int a;
int b;
@@ -577,10 +577,10 @@ NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) {
int *A = Ident(&a);
int *B = Ident(&b);
*A = *B;
- __builtin_longjmp((void**)buf, 1);
+ _longjmp(buf, 1);
}
-NOINLINE void UnderscopeLongJmpFunc1(jmp_buf buf) {
+NOINLINE void SigLongJmpFunc1(sigjmp_buf buf) {
// create three red zones for these two stack objects.
int a;
int b;
@@ -588,10 +588,14 @@ NOINLINE void UnderscopeLongJmpFunc1(jmp_buf buf) {
int *A = Ident(&a);
int *B = Ident(&b);
*A = *B;
- _longjmp(buf, 1);
+ siglongjmp(buf, 1);
}
-NOINLINE void SigLongJmpFunc1(sigjmp_buf buf) {
+#if !defined(__ANDROID__) && !defined(__arm__) && \
+ !defined(__powerpc64__) && !defined(__powerpc__) && \
+ !defined(__aarch64__) && !defined(__mips__) && \
+ !defined(__mips64)
+NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) {
// create three red zones for these two stack objects.
int a;
int b;
@@ -599,12 +603,9 @@ NOINLINE void SigLongJmpFunc1(sigjmp_buf buf) {
int *A = Ident(&a);
int *B = Ident(&b);
*A = *B;
- siglongjmp(buf, 1);
+ __builtin_longjmp((void**)buf, 1);
}
-#if !defined(__ANDROID__) && !defined(__arm__) && \
- !defined(__powerpc64__) && !defined(__powerpc__) && \
- !defined(__aarch64__)
// Does not work on Power and ARM:
// https://code.google.com/p/address-sanitizer/issues/detail?id=185
TEST(AddressSanitizer, BuiltinLongJmpTest) {
@@ -616,7 +617,8 @@ TEST(AddressSanitizer, BuiltinLongJmpTest) {
}
}
#endif // !defined(__ANDROID__) && !defined(__powerpc64__) &&
- // !defined(__powerpc__) && !defined(__arm__)
+ // !defined(__powerpc__) && !defined(__arm__) &&
+ // !defined(__mips__) && !defined(__mips64)
TEST(AddressSanitizer, UnderscopeLongJmpTest) {
static jmp_buf buf;
@@ -1243,7 +1245,7 @@ TEST(AddressSanitizer, DISABLED_DemoTooMuchMemoryTest) {
const size_t kAllocSize = (1 << 28) - 1024;
size_t total_size = 0;
while (true) {
- char *x = (char*)malloc(kAllocSize);
+ void *x = malloc(kAllocSize);
memset(x, 0, kAllocSize);
total_size += kAllocSize;
fprintf(stderr, "total: %ldM %p\n", (long)total_size >> 20, x);