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 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 | 6 |
7 #include "base/process/memory.h" | 7 #include "base/process/memory.h" |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include <windows.h> | 17 #include <windows.h> |
18 #endif | 18 #endif |
19 #if defined(OS_POSIX) | 19 #if defined(OS_POSIX) |
20 #include <errno.h> | 20 #include <errno.h> |
21 #endif | 21 #endif |
22 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
23 #include <malloc/malloc.h> | 23 #include <malloc/malloc.h> |
24 #include "base/mac/mac_util.h" | 24 #include "base/mac/mac_util.h" |
25 #include "base/process/memory_unittest_mac.h" | 25 #include "base/process/memory_unittest_mac.h" |
26 #endif | 26 #endif |
27 #if defined(OS_LINUX) | 27 #if defined(OS_LINUX) |
28 #include <malloc.h> | 28 #include <malloc.h> |
| 29 #include "base/test/malloc_wrapper.h" |
29 #endif | 30 #endif |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 // HeapQueryInformation function pointer. | 33 // HeapQueryInformation function pointer. |
33 typedef BOOL (WINAPI* HeapQueryFn) \ | 34 typedef BOOL (WINAPI* HeapQueryFn) \ |
34 (HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T); | 35 (HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T); |
35 | 36 |
36 const int kConstantInModule = 42; | 37 const int kConstantInModule = 42; |
37 | 38 |
38 TEST(ProcessMemoryTest, GetModuleFromAddress) { | 39 TEST(ProcessMemoryTest, GetModuleFromAddress) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 99 } |
99 #endif // defined(OS_WIN) | 100 #endif // defined(OS_WIN) |
100 | 101 |
101 #if defined(OS_MACOSX) | 102 #if defined(OS_MACOSX) |
102 | 103 |
103 // For the following Mac tests: | 104 // For the following Mac tests: |
104 // Note that base::EnableTerminationOnHeapCorruption() is called as part of | 105 // Note that base::EnableTerminationOnHeapCorruption() is called as part of |
105 // test suite setup and does not need to be done again, else mach_override | 106 // test suite setup and does not need to be done again, else mach_override |
106 // will fail. | 107 // will fail. |
107 | 108 |
108 #if !defined(ADDRESS_SANITIZER) | |
109 // The following code tests the system implementation of malloc() thus no need | |
110 // to test it under AddressSanitizer. | |
111 TEST(ProcessMemoryTest, MacMallocFailureDoesNotTerminate) { | |
112 #if ARCH_CPU_32_BITS | |
113 // The Mavericks malloc library changed in a way which breaks the tricks used | |
114 // to implement EnableTerminationOnOutOfMemory() with UncheckedMalloc() under | |
115 // 32-bit. Under 64-bit the oom_killer code handles this. | |
116 if (base::mac::IsOSMavericksOrLater()) | |
117 return; | |
118 #endif | |
119 | |
120 // Test that ENOMEM doesn't crash via CrMallocErrorBreak two ways: the exit | |
121 // code and lack of the error string. The number of bytes is one less than | |
122 // MALLOC_ABSOLUTE_MAX_SIZE, more than which the system early-returns NULL and | |
123 // does not call through malloc_error_break(). See the comment at | |
124 // EnableTerminationOnOutOfMemory() for more information. | |
125 void* buf = NULL; | |
126 ASSERT_EXIT( | |
127 { | |
128 base::EnableTerminationOnOutOfMemory(); | |
129 | |
130 buf = malloc(std::numeric_limits<size_t>::max() - (2 * PAGE_SIZE) - 1); | |
131 }, | |
132 testing::KilledBySignal(SIGTRAP), | |
133 "\\*\\*\\* error: can't allocate region.*\\n?.*"); | |
134 | |
135 base::debug::Alias(buf); | |
136 } | |
137 #endif // !defined(ADDRESS_SANITIZER) | |
138 | |
139 TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) { | 109 TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) { |
140 // Assert that freeing an unallocated pointer will crash the process. | 110 // Assert that freeing an unallocated pointer will crash the process. |
141 char buf[9]; | 111 char buf[9]; |
142 asm("" : "=r" (buf)); // Prevent clang from being too smart. | 112 asm("" : "=r" (buf)); // Prevent clang from being too smart. |
143 #if ARCH_CPU_64_BITS | 113 #if ARCH_CPU_64_BITS |
144 // On 64 bit Macs, the malloc system automatically abort()s on heap corruption | 114 // On 64 bit Macs, the malloc system automatically abort()s on heap corruption |
145 // but does not output anything. | 115 // but does not output anything. |
146 ASSERT_DEATH(free(buf), ""); | 116 ASSERT_DEATH(free(buf), ""); |
147 #elif defined(ADDRESS_SANITIZER) | 117 #elif defined(ADDRESS_SANITIZER) |
148 // AddressSanitizer replaces malloc() and prints a different error message on | 118 // AddressSanitizer replaces malloc() and prints a different error message on |
149 // heap corruption. | 119 // heap corruption. |
150 ASSERT_DEATH(free(buf), "attempting free on address which " | 120 ASSERT_DEATH(free(buf), "attempting free on address which " |
151 "was not malloc\\(\\)-ed"); | 121 "was not malloc\\(\\)-ed"); |
152 #else | 122 #else |
153 ADD_FAILURE() << "This test is not supported in this build configuration."; | 123 ADD_FAILURE() << "This test is not supported in this build configuration."; |
154 #endif | 124 #endif |
155 } | 125 } |
156 | 126 |
157 #endif // defined(OS_MACOSX) | 127 #endif // defined(OS_MACOSX) |
158 | 128 |
159 // Android doesn't implement set_new_handler, so we can't use the | 129 // Android doesn't implement set_new_handler, so we can't use the |
160 // OutOfMemoryTest cases. | 130 // OutOfMemoryTest cases. OpenBSD does not support these tests either. |
161 // OpenBSD does not support these tests either. | 131 // Don't test these on ASan/TSan/MSan configurations: only test the real |
| 132 // allocator. |
162 // TODO(vandebo) make this work on Windows too. | 133 // TODO(vandebo) make this work on Windows too. |
163 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && \ | 134 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !defined(OS_WIN) && \ |
164 !defined(OS_WIN) | 135 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
165 | 136 |
166 #if defined(USE_TCMALLOC) | 137 #if defined(USE_TCMALLOC) |
167 extern "C" { | 138 extern "C" { |
168 int tc_set_new_mode(int mode); | 139 int tc_set_new_mode(int mode); |
169 } | 140 } |
170 #endif // defined(USE_TCMALLOC) | 141 #endif // defined(USE_TCMALLOC) |
171 | 142 |
| 143 namespace { |
| 144 const char *kOomRegex = "Out of memory"; |
| 145 } // namespace |
| 146 |
172 class OutOfMemoryTest : public testing::Test { | 147 class OutOfMemoryTest : public testing::Test { |
173 public: | 148 public: |
174 OutOfMemoryTest() | 149 OutOfMemoryTest() |
175 : value_(NULL), | 150 : value_(NULL), |
176 // Make test size as large as possible minus a few pages so | 151 // Make test size as large as possible minus a few pages so |
177 // that alignment or other rounding doesn't make it wrap. | 152 // that alignment or other rounding doesn't make it wrap. |
178 test_size_(std::numeric_limits<std::size_t>::max() - 12 * 1024), | 153 test_size_(std::numeric_limits<std::size_t>::max() - 12 * 1024), |
179 signed_test_size_(std::numeric_limits<ssize_t>::max()) { | 154 signed_test_size_(std::numeric_limits<ssize_t>::max()) { |
180 } | 155 } |
181 | 156 |
(...skipping 18 matching lines...) Expand all Loading... |
200 // tests shouldn't be started in a multithread environment, this call | 175 // tests shouldn't be started in a multithread environment, this call |
201 // should be done inside of the ASSERT_DEATH. | 176 // should be done inside of the ASSERT_DEATH. |
202 base::EnableTerminationOnOutOfMemory(); | 177 base::EnableTerminationOnOutOfMemory(); |
203 } | 178 } |
204 }; | 179 }; |
205 | 180 |
206 TEST_F(OutOfMemoryDeathTest, New) { | 181 TEST_F(OutOfMemoryDeathTest, New) { |
207 ASSERT_DEATH({ | 182 ASSERT_DEATH({ |
208 SetUpInDeathAssert(); | 183 SetUpInDeathAssert(); |
209 value_ = operator new(test_size_); | 184 value_ = operator new(test_size_); |
210 }, ""); | 185 }, kOomRegex); |
211 } | 186 } |
212 | 187 |
213 TEST_F(OutOfMemoryDeathTest, NewArray) { | 188 TEST_F(OutOfMemoryDeathTest, NewArray) { |
214 ASSERT_DEATH({ | 189 ASSERT_DEATH({ |
215 SetUpInDeathAssert(); | 190 SetUpInDeathAssert(); |
216 value_ = new char[test_size_]; | 191 value_ = new char[test_size_]; |
217 }, ""); | 192 }, kOomRegex); |
218 } | 193 } |
219 | 194 |
220 TEST_F(OutOfMemoryDeathTest, Malloc) { | 195 TEST_F(OutOfMemoryDeathTest, Malloc) { |
221 ASSERT_DEATH({ | 196 ASSERT_DEATH({ |
222 SetUpInDeathAssert(); | 197 SetUpInDeathAssert(); |
223 value_ = malloc(test_size_); | 198 value_ = malloc(test_size_); |
224 }, ""); | 199 }, kOomRegex); |
225 } | 200 } |
226 | 201 |
227 TEST_F(OutOfMemoryDeathTest, Realloc) { | 202 TEST_F(OutOfMemoryDeathTest, Realloc) { |
228 ASSERT_DEATH({ | 203 ASSERT_DEATH({ |
229 SetUpInDeathAssert(); | 204 SetUpInDeathAssert(); |
230 value_ = realloc(NULL, test_size_); | 205 value_ = realloc(NULL, test_size_); |
231 }, ""); | 206 }, kOomRegex); |
232 } | 207 } |
233 | 208 |
234 TEST_F(OutOfMemoryDeathTest, Calloc) { | 209 TEST_F(OutOfMemoryDeathTest, Calloc) { |
235 ASSERT_DEATH({ | 210 ASSERT_DEATH({ |
236 SetUpInDeathAssert(); | 211 SetUpInDeathAssert(); |
237 value_ = calloc(1024, test_size_ / 1024L); | 212 value_ = calloc(1024, test_size_ / 1024L); |
238 }, ""); | 213 }, kOomRegex); |
239 } | 214 } |
240 | 215 |
241 TEST_F(OutOfMemoryDeathTest, Valloc) { | 216 TEST_F(OutOfMemoryDeathTest, Valloc) { |
242 ASSERT_DEATH({ | 217 ASSERT_DEATH({ |
243 SetUpInDeathAssert(); | 218 SetUpInDeathAssert(); |
244 value_ = valloc(test_size_); | 219 value_ = valloc(test_size_); |
245 }, ""); | 220 }, kOomRegex); |
246 } | 221 } |
247 | 222 |
248 #if defined(OS_LINUX) | 223 #if defined(OS_LINUX) |
249 | 224 |
250 #if PVALLOC_AVAILABLE == 1 | 225 #if PVALLOC_AVAILABLE == 1 |
251 TEST_F(OutOfMemoryDeathTest, Pvalloc) { | 226 TEST_F(OutOfMemoryDeathTest, Pvalloc) { |
252 ASSERT_DEATH({ | 227 ASSERT_DEATH({ |
253 SetUpInDeathAssert(); | 228 SetUpInDeathAssert(); |
254 value_ = pvalloc(test_size_); | 229 value_ = pvalloc(test_size_); |
255 }, ""); | 230 }, kOomRegex); |
256 } | 231 } |
257 #endif // PVALLOC_AVAILABLE == 1 | 232 #endif // PVALLOC_AVAILABLE == 1 |
258 | 233 |
259 TEST_F(OutOfMemoryDeathTest, Memalign) { | 234 TEST_F(OutOfMemoryDeathTest, Memalign) { |
260 ASSERT_DEATH({ | 235 ASSERT_DEATH({ |
261 SetUpInDeathAssert(); | 236 SetUpInDeathAssert(); |
262 value_ = memalign(4, test_size_); | 237 value_ = memalign(4, test_size_); |
263 }, ""); | 238 }, kOomRegex); |
264 } | 239 } |
265 | 240 |
266 TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { | 241 TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { |
267 // This tests that the run-time symbol resolution is overriding malloc for | 242 // This tests that the run-time symbol resolution is overriding malloc for |
268 // shared libraries (including libc itself) as well as for our code. | 243 // shared libraries as well as for our code. |
269 std::string format = base::StringPrintf("%%%zud", test_size_); | |
270 char *value = NULL; | |
271 ASSERT_DEATH({ | 244 ASSERT_DEATH({ |
272 SetUpInDeathAssert(); | 245 SetUpInDeathAssert(); |
273 EXPECT_EQ(-1, asprintf(&value, format.c_str(), 0)); | 246 value_ = MallocWrapper(test_size_); |
274 }, ""); | 247 }, kOomRegex); |
275 } | 248 } |
276 #endif // OS_LINUX | 249 #endif // OS_LINUX |
277 | 250 |
278 // Android doesn't implement posix_memalign(). | 251 // Android doesn't implement posix_memalign(). |
279 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 252 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
280 TEST_F(OutOfMemoryDeathTest, Posix_memalign) { | 253 TEST_F(OutOfMemoryDeathTest, Posix_memalign) { |
281 // Grab the return value of posix_memalign to silence a compiler warning | 254 // Grab the return value of posix_memalign to silence a compiler warning |
282 // about unused return values. We don't actually care about the return | 255 // about unused return values. We don't actually care about the return |
283 // value, since we're asserting death. | 256 // value, since we're asserting death. |
284 ASSERT_DEATH({ | 257 ASSERT_DEATH({ |
285 SetUpInDeathAssert(); | 258 SetUpInDeathAssert(); |
286 EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)); | 259 EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)); |
287 }, ""); | 260 }, kOomRegex); |
288 } | 261 } |
289 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) | 262 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
290 | 263 |
291 #if defined(OS_MACOSX) | 264 #if defined(OS_MACOSX) |
292 | 265 |
293 // Purgeable zone tests | 266 // Purgeable zone tests |
294 | 267 |
295 TEST_F(OutOfMemoryDeathTest, MallocPurgeable) { | 268 TEST_F(OutOfMemoryDeathTest, MallocPurgeable) { |
296 malloc_zone_t* zone = malloc_default_purgeable_zone(); | 269 malloc_zone_t* zone = malloc_default_purgeable_zone(); |
297 ASSERT_DEATH({ | 270 ASSERT_DEATH({ |
298 SetUpInDeathAssert(); | 271 SetUpInDeathAssert(); |
299 value_ = malloc_zone_malloc(zone, test_size_); | 272 value_ = malloc_zone_malloc(zone, test_size_); |
300 }, ""); | 273 }, kOomRegex); |
301 } | 274 } |
302 | 275 |
303 TEST_F(OutOfMemoryDeathTest, ReallocPurgeable) { | 276 TEST_F(OutOfMemoryDeathTest, ReallocPurgeable) { |
304 malloc_zone_t* zone = malloc_default_purgeable_zone(); | 277 malloc_zone_t* zone = malloc_default_purgeable_zone(); |
305 ASSERT_DEATH({ | 278 ASSERT_DEATH({ |
306 SetUpInDeathAssert(); | 279 SetUpInDeathAssert(); |
307 value_ = malloc_zone_realloc(zone, NULL, test_size_); | 280 value_ = malloc_zone_realloc(zone, NULL, test_size_); |
308 }, ""); | 281 }, kOomRegex); |
309 } | 282 } |
310 | 283 |
311 TEST_F(OutOfMemoryDeathTest, CallocPurgeable) { | 284 TEST_F(OutOfMemoryDeathTest, CallocPurgeable) { |
312 malloc_zone_t* zone = malloc_default_purgeable_zone(); | 285 malloc_zone_t* zone = malloc_default_purgeable_zone(); |
313 ASSERT_DEATH({ | 286 ASSERT_DEATH({ |
314 SetUpInDeathAssert(); | 287 SetUpInDeathAssert(); |
315 value_ = malloc_zone_calloc(zone, 1024, test_size_ / 1024L); | 288 value_ = malloc_zone_calloc(zone, 1024, test_size_ / 1024L); |
316 }, ""); | 289 }, kOomRegex); |
317 } | 290 } |
318 | 291 |
319 TEST_F(OutOfMemoryDeathTest, VallocPurgeable) { | 292 TEST_F(OutOfMemoryDeathTest, VallocPurgeable) { |
320 malloc_zone_t* zone = malloc_default_purgeable_zone(); | 293 malloc_zone_t* zone = malloc_default_purgeable_zone(); |
321 ASSERT_DEATH({ | 294 ASSERT_DEATH({ |
322 SetUpInDeathAssert(); | 295 SetUpInDeathAssert(); |
323 value_ = malloc_zone_valloc(zone, test_size_); | 296 value_ = malloc_zone_valloc(zone, test_size_); |
324 }, ""); | 297 }, kOomRegex); |
325 } | 298 } |
326 | 299 |
327 TEST_F(OutOfMemoryDeathTest, PosixMemalignPurgeable) { | 300 TEST_F(OutOfMemoryDeathTest, PosixMemalignPurgeable) { |
328 malloc_zone_t* zone = malloc_default_purgeable_zone(); | 301 malloc_zone_t* zone = malloc_default_purgeable_zone(); |
329 ASSERT_DEATH({ | 302 ASSERT_DEATH({ |
330 SetUpInDeathAssert(); | 303 SetUpInDeathAssert(); |
331 value_ = malloc_zone_memalign(zone, 8, test_size_); | 304 value_ = malloc_zone_memalign(zone, 8, test_size_); |
332 }, ""); | 305 }, kOomRegex); |
333 } | 306 } |
334 | 307 |
335 // Since these allocation functions take a signed size, it's possible that | 308 // Since these allocation functions take a signed size, it's possible that |
336 // calling them just once won't be enough to exhaust memory. In the 32-bit | 309 // calling them just once won't be enough to exhaust memory. In the 32-bit |
337 // environment, it's likely that these allocation attempts will fail because | 310 // environment, it's likely that these allocation attempts will fail because |
338 // not enough contiguous address space is available. In the 64-bit environment, | 311 // not enough contiguous address space is available. In the 64-bit environment, |
339 // it's likely that they'll fail because they would require a preposterous | 312 // it's likely that they'll fail because they would require a preposterous |
340 // amount of (virtual) memory. | 313 // amount of (virtual) memory. |
341 | 314 |
342 TEST_F(OutOfMemoryDeathTest, CFAllocatorSystemDefault) { | 315 TEST_F(OutOfMemoryDeathTest, CFAllocatorSystemDefault) { |
343 ASSERT_DEATH({ | 316 ASSERT_DEATH({ |
344 SetUpInDeathAssert(); | 317 SetUpInDeathAssert(); |
345 while ((value_ = | 318 while ((value_ = |
346 base::AllocateViaCFAllocatorSystemDefault(signed_test_size_))) {} | 319 base::AllocateViaCFAllocatorSystemDefault(signed_test_size_))) {} |
347 }, ""); | 320 }, kOomRegex); |
348 } | 321 } |
349 | 322 |
350 TEST_F(OutOfMemoryDeathTest, CFAllocatorMalloc) { | 323 TEST_F(OutOfMemoryDeathTest, CFAllocatorMalloc) { |
351 ASSERT_DEATH({ | 324 ASSERT_DEATH({ |
352 SetUpInDeathAssert(); | 325 SetUpInDeathAssert(); |
353 while ((value_ = | 326 while ((value_ = |
354 base::AllocateViaCFAllocatorMalloc(signed_test_size_))) {} | 327 base::AllocateViaCFAllocatorMalloc(signed_test_size_))) {} |
355 }, ""); | 328 }, kOomRegex); |
356 } | 329 } |
357 | 330 |
358 TEST_F(OutOfMemoryDeathTest, CFAllocatorMallocZone) { | 331 TEST_F(OutOfMemoryDeathTest, CFAllocatorMallocZone) { |
359 ASSERT_DEATH({ | 332 ASSERT_DEATH({ |
360 SetUpInDeathAssert(); | 333 SetUpInDeathAssert(); |
361 while ((value_ = | 334 while ((value_ = |
362 base::AllocateViaCFAllocatorMallocZone(signed_test_size_))) {} | 335 base::AllocateViaCFAllocatorMallocZone(signed_test_size_))) {} |
363 }, ""); | 336 }, kOomRegex); |
364 } | 337 } |
365 | 338 |
366 #if !defined(ARCH_CPU_64_BITS) | 339 #if !defined(ARCH_CPU_64_BITS) |
367 | 340 |
368 // See process_util_unittest_mac.mm for an explanation of why this test isn't | 341 // See process_util_unittest_mac.mm for an explanation of why this test isn't |
369 // run in the 64-bit environment. | 342 // run in the 64-bit environment. |
370 | 343 |
371 TEST_F(OutOfMemoryDeathTest, PsychoticallyBigObjCObject) { | 344 TEST_F(OutOfMemoryDeathTest, PsychoticallyBigObjCObject) { |
372 ASSERT_DEATH({ | 345 ASSERT_DEATH({ |
373 SetUpInDeathAssert(); | 346 SetUpInDeathAssert(); |
374 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} | 347 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} |
375 }, ""); | 348 }, kOomRegex); |
376 } | 349 } |
377 | 350 |
378 #endif // !ARCH_CPU_64_BITS | 351 #endif // !ARCH_CPU_64_BITS |
379 #endif // OS_MACOSX | 352 #endif // OS_MACOSX |
380 | 353 |
381 class OutOfMemoryHandledTest : public OutOfMemoryTest { | 354 class OutOfMemoryHandledTest : public OutOfMemoryTest { |
382 public: | 355 public: |
383 static const size_t kSafeMallocSize = 512; | 356 static const size_t kSafeMallocSize = 512; |
384 static const size_t kSafeCallocSize = 128; | 357 static const size_t kSafeCallocSize = 128; |
385 static const size_t kSafeCallocItems = 4; | 358 static const size_t kSafeCallocItems = 4; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 EXPECT_TRUE(value_ != NULL); | 408 EXPECT_TRUE(value_ != NULL); |
436 bytes = static_cast<const char*>(value_); | 409 bytes = static_cast<const char*>(value_); |
437 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) | 410 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) |
438 EXPECT_EQ(0, bytes[i]); | 411 EXPECT_EQ(0, bytes[i]); |
439 free(value_); | 412 free(value_); |
440 | 413 |
441 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); | 414 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); |
442 EXPECT_TRUE(value_ == NULL); | 415 EXPECT_TRUE(value_ == NULL); |
443 } | 416 } |
444 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 417 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
445 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !defined(OS_WIN) | 418 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !defined(OS_WIN) && |
| 419 // !defined(ADDRESS_SANITIZER) |
OLD | NEW |