ASAN HugeMallocTest fails

This is with openSUSE 13.1 x86-64:

FAIL: AddressSanitizer-Unit :: Asan-x86_64-Test/AddressSanitizer.HugeMallocTest (50 of 16790)
******************** TEST ‘AddressSanitizer-Unit :: Asan-x86_64-Test/AddressSanitizer.HugeMallocTest’ FAILED ********************
Note: Google Test filter = AddressSanitizer.HugeMallocTest
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from AddressSanitizer
[ RUN ] AddressSanitizer.HugeMallocTest
/home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/tests/asan_test.cc:291: Failure
Death test: Ident((char*)malloc(size))[-1] = 0
Result: died but not with expected error.
Expected: is located 1 bytes to the left of 4299161600-byte
Actual msg:
[ DEATH ] ==18032==ERROR: AddressSanitizer failed to allocate 0x100402000 (4299169792) bytes of LargeMmapAllocator: 12
[ DEATH ] ==18032==Process memory map follows:
[ DEATH ] 0x000000400000-0x0000006f6000 /home/abuild/rpmbuild/BUILD/llvm/stage2/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test
[ DEATH ] 0x0000008f5000-0x0000008f8000 /home/abuild/rpmbuild/BUILD/llvm/stage2/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test
[ DEATH ] 0x0000008f8000-0x00000090e000 /home/abuild/rpmbuild/BUILD/llvm/stage2/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test
[ DEATH ] 0x00000090e000-0x000001d68000
[ DEATH ] 0x00007fff7000-0x00008fff7000
[ DEATH ] 0x00008fff7000-0x02008fff7000
[ DEATH ] 0x02008fff7000-0x10007fff8000
[ DEATH ] 0x600000000000-0x602000000000
[ DEATH ] 0x602000000000-0x602000010000
[ DEATH ] 0x602000010000-0x603000000000
[ DEATH ] 0x603000000000-0x603000010000
[ DEATH ] 0x603000010000-0x604000000000
[ DEATH ] 0x604000000000-0x604000010000
[ DEATH ] 0x604000010000-0x606000000000
[ DEATH ] 0x606000000000-0x606000010000
[ DEATH ] 0x606000010000-0x607000000000
[ DEATH ] 0x607000000000-0x607000010000
[ DEATH ] 0x607000010000-0x608000000000
[ DEATH ] 0x608000000000-0x608000010000
[ DEATH ] 0x608000010000-0x60b000000000
[ DEATH ] 0x60b000000000-0x60b000010000
[ DEATH ] 0x60b000010000-0x60c000000000
[ DEATH ] 0x60c000000000-0x60c000010000
[ DEATH ] 0x60c000010000-0x60e000000000
[ DEATH ] 0x60e000000000-0x60e000010000
[ DEATH ] 0x60e000010000-0x60f000000000
[ DEATH ] 0x60f000000000-0x60f000010000
[ DEATH ] 0x60f000010000-0x611000000000
[ DEATH ] 0x611000000000-0x611000010000
[ DEATH ] 0x611000010000-0x613000000000
[ DEATH ] 0x613000000000-0x613000010000
[ DEATH ] 0x613000010000-0x614000000000
[ DEATH ] 0x614000000000-0x614000020000
[ DEATH ] 0x614000020000-0x615000000000
[ DEATH ] 0x615000000000-0x615000020000
[ DEATH ] 0x615000020000-0x616000000000
[ DEATH ] 0x616000000000-0x616000020000
[ DEATH ] 0x616000020000-0x618000000000
[ DEATH ] 0x618000000000-0x618000020000
[ DEATH ] 0x618000020000-0x619000000000
[ DEATH ] 0x619000000000-0x619000020000
[ DEATH ] 0x619000020000-0x61c000000000
[ DEATH ] 0x61c000000000-0x61c000020000
[ DEATH ] 0x61c000020000-0x624000000000
[ DEATH ] 0x624000000000-0x624000020000
[ DEATH ] 0x624000020000-0x640000000000
[ DEATH ] 0x640000000000-0x640000003000
[ DEATH ] 0x7f28a2000000-0x7f28a3000000
[ DEATH ] 0x7f28a4000000-0x7f28a7000000
[ DEATH ] 0x7f28a8000000-0x7f28a9000000
[ DEATH ] 0x7f28a9a32000-0x7f28a9d38000
[ DEATH ] 0x7f28a9d38000-0x7f28a9edd000 /lib64/libc-2.18.so
[ DEATH ] 0x7f28a9edd000-0x7f28aa0dd000 /lib64/libc-2.18.so
[ DEATH ] 0x7f28aa0dd000-0x7f28aa0e1000 /lib64/libc-2.18.so
[ DEATH ] 0x7f28aa0e1000-0x7f28aa0e3000 /lib64/libc-2.18.so
[ DEATH ] 0x7f28aa0e3000-0x7f28aa0e7000
[ DEATH ] 0x7f28aa0e7000-0x7f28aa0fd000 /lib64/libgcc_s.so.1
[ DEATH ] 0x7f28aa0fd000-0x7f28aa2fc000 /lib64/libgcc_s.so.1
[ DEATH ] 0x7f28aa2fc000-0x7f28aa2fd000 /lib64/libgcc_s.so.1
[ DEATH ] 0x7f28aa2fd000-0x7f28aa2fe000 /lib64/libgcc_s.so.1
[ DEATH ] 0x7f28aa2fe000-0x7f28aa400000 /lib64/libm-2.18.so
[ DEATH ] 0x7f28aa400000-0x7f28aa5ff000 /lib64/libm-2.18.so
[ DEATH ] 0x7f28aa5ff000-0x7f28aa600000 /lib64/libm-2.18.so
[ DEATH ] 0x7f28aa600000-0x7f28aa601000 /lib64/libm-2.18.so
[ DEATH ] 0x7f28aa601000-0x7f28aa604000 /lib64/libdl-2.18.so
[ DEATH ] 0x7f28aa604000-0x7f28aa803000 /lib64/libdl-2.18.so
[ DEATH ] 0x7f28aa803000-0x7f28aa804000 /lib64/libdl-2.18.so
[ DEATH ] 0x7f28aa804000-0x7f28aa805000 /lib64/libdl-2.18.so
[ DEATH ] 0x7f28aa805000-0x7f28aa81d000 /lib64/libpthread-2.18.so
[ DEATH ] 0x7f28aa81d000-0x7f28aaa1d000 /lib64/libpthread-2.18.so
[ DEATH ] 0x7f28aaa1d000-0x7f28aaa1e000 /lib64/libpthread-2.18.so
[ DEATH ] 0x7f28aaa1e000-0x7f28aaa1f000 /lib64/libpthread-2.18.so
[ DEATH ] 0x7f28aaa1f000-0x7f28aaa23000
[ DEATH ] 0x7f28aaa23000-0x7f28aab0d000 /usr/lib64/libstdc++.so.6.0.18
[ DEATH ] 0x7f28aab0d000-0x7f28aad0c000 /usr/lib64/libstdc++.so.6.0.18
[ DEATH ] 0x7f28aad0c000-0x7f28aad14000 /usr/lib64/libstdc++.so.6.0.18
[ DEATH ] 0x7f28aad14000-0x7f28aad16000 /usr/lib64/libstdc++.so.6.0.18
[ DEATH ] 0x7f28aad16000-0x7f28aad2b000
[ DEATH ] 0x7f28aad2b000-0x7f28aad4b000 /lib64/ld-2.18.so
[ DEATH ] 0x7f28aaf15000-0x7f28aaf47000
[ DEATH ] 0x7f28aaf47000-0x7f28aaf4a000
[ DEATH ] 0x7f28aaf4a000-0x7f28aaf4b000 /lib64/ld-2.18.so
[ DEATH ] 0x7f28aaf4b000-0x7f28aaf4c000 /lib64/ld-2.18.so
[ DEATH ] 0x7f28aaf4c000-0x7f28aaf4d000
[ DEATH ] 0x7fff77459000-0x7fff7747a000 [stack]
[ DEATH ] 0x7fff775ff000-0x7fff77600000 [vdso]
[ DEATH ] 0xffffffffff600000-0xffffffffff601000 [vsyscall]
[ DEATH ] ==18032==End of process memory map.
[ DEATH ] ==18032==AddressSanitizer CHECK failed: /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:68 “((“unable to mmap” && 0)) != (0)” (0x0, 0x0)
[ DEATH ] #0 0x45f82c in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:66
[ DEATH ] #1 0x462a81 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:69
[ DEATH ] #2 0x466bee in RoundUpTo /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.h:261
[ DEATH ] #3 0x466bee in __sanitizer::MmapOrDie(unsigned long, char const*) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:51
[ DEATH ] #4 0x425298 in __sanitizer::LargeMmapAllocator<__asan::AsanMapUnmapCallback>::Allocate(__sanitizer::AllocatorStats*, unsigned long, unsigned long) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/…/sanitizer_common/sanitizer_allocator.h:949
[ DEATH ] #5 0x42514e in __sanitizer::CombinedAllocator<__sanitizer::SizeClassAllocator64<105553116266496ul, 4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>, __asan::AsanMapUnmapCallback>, __sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator64<105553116266496ul, 4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>, __asan::AsanMapUnmapCallback> >, __sanitizer::LargeMmapAllocator<__asan::AsanMapUnmapCallback> >::Allocate(__sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator64<105553116266496ul, 4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>, __asan::AsanMapUnmapCallback> >, unsigned long, unsigned long, bool) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/…/sanitizer_common/sanitizer_allocator.h:1190
[ DEATH ] #6 0x421117 in __asan::Allocate(unsigned long, unsigned long, __sanitizer::StackTrace
, __asan::AllocType, bool) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/asan_allocator2.cc:354
[ DEATH ] #7 0x4599c9 in malloc /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:75
[ DEATH ] #8 0x5191cf in TestLargeMalloc(unsigned long) /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/tests/asan_test.cc:291
[ DEATH ] #9 0x4c253b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:2145
[ DEATH ] #10 0x48c13f in testing::Test::Run() /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:2161
[ DEATH ] #11 0x48f06d in testing::TestInfo::Run() /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:2309
[ DEATH ] #12 0x4907c2 in testing::TestCase::Run() /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:2416
[ DEATH ] #13 0x4a0fa4 in testing::internal::UnitTestImpl::RunAllTests() /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:4205
[ DEATH ] #14 0x4c4d8b in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:2145
[ DEATH ] #15 0x4a06ab in testing::UnitTest::Run() /home/abuild/rpmbuild/BUILD/llvm/utils/unittest/googletest/src/gtest.cc:3839
[ DEATH ] #16 0x64db27 in main /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/asan/tests/asan_test_main.cc:18
[ DEATH ] #17 0x7f28a9d59be4 in __libc_start_main (/lib64/libc.so.6+0x21be4)
[ DEATH ] #18 0x46f958 in _start (/home/abuild/rpmbuild/BUILD/llvm/stage2/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x46f958)
[ DEATH ]
[ DEATH ]
[ FAILED ] AddressSanitizer.HugeMallocTest (129 ms)
[----------] 1 test from AddressSanitizer (129 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (129 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] AddressSanitizer.HugeMallocTest

1 FAILED TEST
YOU HAVE 24 DISABLED TESTS

How much memory does your system have?

This is under kvm with 3GB RAM (-m 3000)

This is under kvm with 3GB RAM (-m 3000)

This test tests the ability to allocate 4.1Gb RAM.
It will have to be disabled on small RAM machines somehow.
Or you can run it with 6Gb RAM. This test has been there for quite a while
and you are the first to complain, so maybe running with 6Gb is the right
approach.

--kcc

Uhm ok but this wouldn't work on ARM buildbots since they at most have
1-2GB of RAM. For now I'll just disable this test. Thanks.

Are you referring to ARM (32-bit) or AARCH64 (64-bit)?
This test only fires in 64-bit runs anyway.

32bit but for this to work I need a constraint saying 6GB of RAM is
required and ARM buildbots couldn't satisfy that. This is a quirk on our
side.

    This is under kvm with 3GB RAM (-m 3000)

This test tests the ability to allocate 4.1Gb RAM.
It will have to be disabled on small RAM machines somehow.
Or you can run it with 6Gb RAM. This test has been there for quite a while
and you are the first to complain

I imagine there aren't more complaints because people are just disabling asan on their builders to avoid the cost.

Regardless of whether it's a low-end or high-end system with hundreds of gigabytes RAM, the 4.1 Gb a single test allocates could probably be put to better uses such as additional builders.

, so maybe running with 6Gb is the right approach.

How about gating this behind ASAN_AVOID_EXPENSIVE_TESTS?

Alp.

Like this?
--- asan/tests/asan_test.cc (revision 196066)
+++ asan/tests/asan_test.cc (working copy)
@@ -299,7 +299,7 @@
}

TEST(AddressSanitizer, HugeMallocTest) {
- if (SANITIZER_WORDSIZE != 64) return;
+ if (SANITIZER_WORDSIZE != 64 || ASAN_AVOID_EXPENSIVE_TESTS) return;
   size_t n_megs = 4100;
   TestLargeMalloc(n_megs << 20);
}

Brilliant, that should do the trick.

Thanks kcc

Alp.

done, r196097.