OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains intentional memory errors, some of which may lead to | 5 // This file contains intentional memory errors, some of which may lead to |
6 // crashes if the test is ran without special memory testing tools. We use these | 6 // crashes if the test is ran without special memory testing tools. We use these |
7 // errors to verify the sanity of the tools. | 7 // errors to verify the sanity of the tools. |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/debug/asan_invalid_access.h" | 10 #include "base/debug/asan_invalid_access.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 | 105 |
106 #if (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN) | 106 #if (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN) |
107 // Because iOS doesn't support death tests, each of the following tests will | 107 // Because iOS doesn't support death tests, each of the following tests will |
108 // crash the whole program under Asan. On Windows Asan is based on SyzyAsan; the | 108 // crash the whole program under Asan. On Windows Asan is based on SyzyAsan; the |
109 // error report mechanism is different than with Asan so these tests will fail. | 109 // error report mechanism is different than with Asan so these tests will fail. |
110 #define MAYBE_AccessesToNewMemory DISABLED_AccessesToNewMemory | 110 #define MAYBE_AccessesToNewMemory DISABLED_AccessesToNewMemory |
111 #define MAYBE_AccessesToMallocMemory DISABLED_AccessesToMallocMemory | 111 #define MAYBE_AccessesToMallocMemory DISABLED_AccessesToMallocMemory |
112 #else | 112 #else |
113 #define MAYBE_AccessesToNewMemory AccessesToNewMemory | 113 #define MAYBE_AccessesToNewMemory AccessesToNewMemory |
114 #define MAYBE_AccessesToMallocMemory AccessesToMallocMemory | 114 #define MAYBE_AccessesToMallocMemory AccessesToMallocMemory |
115 #define MAYBE_ArrayDeletedWithoutBraces ArrayDeletedWithoutBraces | |
116 #define MAYBE_SingleElementDeletedWithBraces SingleElementDeletedWithBraces | |
117 #endif | |
118 | 115 |
119 // The following tests pass with Clang r170392, but not r172454, which | 116 // The following tests pass with Clang r170392, but not r172454, which |
120 // makes AddressSanitizer detect errors in them. We disable these tests under | 117 // makes AddressSanitizer detect errors in them. We disable these tests under |
121 // AddressSanitizer until we fully switch to Clang r172454. After that the | 118 // AddressSanitizer until we fully switch to Clang r172454. After that the |
122 // tests should be put back under the (defined(OS_IOS) || defined(OS_WIN)) | 119 // tests should be put back under the (defined(OS_IOS) || defined(OS_WIN)) |
123 // clause above. | 120 // clause above. |
124 // See also http://crbug.com/172614. | 121 // See also http://crbug.com/172614. |
125 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 122 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
126 #define MAYBE_SingleElementDeletedWithBraces \ | 123 #define MAYBE_SingleElementDeletedWithBraces \ |
127 DISABLED_SingleElementDeletedWithBraces | 124 DISABLED_SingleElementDeletedWithBraces |
128 #define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces | 125 #define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces |
129 #endif | 126 #else |
127 #define MAYBE_ArrayDeletedWithoutBraces ArrayDeletedWithoutBraces | |
128 #define MAYBE_SingleElementDeletedWithBraces SingleElementDeletedWithBraces | |
129 #endif // defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | |
130 | |
131 #endif // (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN) | |
Nico
2014/07/16 19:02:29
Are you sure this endif should move to down here?
tzik
2014/07/17 06:05:42
Ah, right. This should move above.
Done.
| |
130 TEST(ToolsSanityTest, MAYBE_AccessesToNewMemory) { | 132 TEST(ToolsSanityTest, MAYBE_AccessesToNewMemory) { |
131 char *foo = new char[10]; | 133 char *foo = new char[10]; |
132 MakeSomeErrors(foo, 10); | 134 MakeSomeErrors(foo, 10); |
133 delete [] foo; | 135 delete [] foo; |
134 // Use after delete. | 136 // Use after delete. |
135 HARMFUL_ACCESS(foo[5] = 0, "heap-use-after-free"); | 137 HARMFUL_ACCESS(foo[5] = 0, "heap-use-after-free"); |
136 } | 138 } |
137 | 139 |
138 TEST(ToolsSanityTest, MAYBE_AccessesToMallocMemory) { | 140 TEST(ToolsSanityTest, MAYBE_AccessesToMallocMemory) { |
139 char *foo = reinterpret_cast<char*>(malloc(10)); | 141 char *foo = reinterpret_cast<char*>(malloc(10)); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 | 321 |
320 TEST(ToolsSanityTest, AtomicsAreIgnored) { | 322 TEST(ToolsSanityTest, AtomicsAreIgnored) { |
321 base::subtle::Atomic32 shared = 0; | 323 base::subtle::Atomic32 shared = 0; |
322 ReleaseStoreThread thread1(&shared); | 324 ReleaseStoreThread thread1(&shared); |
323 AcquireLoadThread thread2(&shared); | 325 AcquireLoadThread thread2(&shared); |
324 RunInParallel(&thread1, &thread2); | 326 RunInParallel(&thread1, &thread2); |
325 EXPECT_EQ(kMagicValue, shared); | 327 EXPECT_EQ(kMagicValue, shared); |
326 } | 328 } |
327 | 329 |
328 } // namespace base | 330 } // namespace base |
OLD | NEW |