From b1bd641078aa104ac87a556901eac0565e3ca16f Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Wed, 15 May 2013 08:59:28 +0000 Subject: [PATCH] Various minor cctest fixes to make ASAN a bit happier. * Running with ASAN needs more stack, so don't set resource constraints too tight. * Checking boot time memory usage doesn't make sense when running with ASAN, it eats tons of memory for itself. * Fixed a malloc/delete[] mismatch: Not surprisingly, the pointer wrapped by a SmartArrayPointer should better be allocated by, well, NewArray... Even with these 3 fixes, we still have a few failures when running our test suite with ASAN. Most of them are either timeouts or failures caused by greatly increased stack usage. R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/15096011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14674 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/cctest/test-api.cc | 10 ++++++---- test/cctest/test-mark-compact.cc | 11 +++++++++-- test/cctest/test-parsing.cc | 3 +-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4fccce6..2093dbb 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -15883,9 +15883,12 @@ static uint32_t* ComputeStackLimit(uint32_t size) { } +// We need at least 165kB for an x64 debug build with clang and ASAN. +static const int stack_breathing_room = 256 * i::KB; + + TEST(SetResourceConstraints) { - static const int K = 1024; - uint32_t* set_limit = ComputeStackLimit(128 * K); + uint32_t* set_limit = ComputeStackLimit(stack_breathing_room); // Set stack limit. v8::ResourceConstraints constraints; @@ -15909,8 +15912,7 @@ TEST(SetResourceConstraintsInThread) { uint32_t* set_limit; { v8::Locker locker(CcTest::default_isolate()); - static const int K = 1024; - set_limit = ComputeStackLimit(128 * K); + set_limit = ComputeStackLimit(stack_breathing_room); // Set stack limit. v8::ResourceConstraints constraints; diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc index 2cb4646..dc21ac2 100644 --- a/test/cctest/test-mark-compact.cc +++ b/test/cctest/test-mark-compact.cc @@ -467,10 +467,17 @@ TEST(EmptyObjectGroups) { } +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define V8_WITH_ASAN 1 +#endif +#endif + + // Here is a memory use test that uses /proc, and is therefore Linux-only. We // do not care how much memory the simulator uses, since it is only there for -// debugging purposes. -#if defined(__linux__) && !defined(USE_SIMULATOR) +// debugging purposes. Testing with ASAN doesn't make sense, either. +#if defined(__linux__) && !defined(USE_SIMULATOR) && !defined(V8_WITH_ASAN) static uintptr_t ReadLong(char* buffer, intptr_t* position, int base) { diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index 05fea0b..170ec76 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -388,8 +388,7 @@ TEST(PreParseOverflow) { reinterpret_cast(&marker) - 128 * 1024); size_t kProgramSize = 1024 * 1024; - i::SmartArrayPointer program( - reinterpret_cast(malloc(kProgramSize + 1))); + i::SmartArrayPointer program(i::NewArray(kProgramSize + 1)); memset(*program, '(', kProgramSize); program[kProgramSize] = '\0'; -- 2.7.4