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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 "(Terminating process due to a potential for future heap " | 497 "(Terminating process due to a potential for future heap " |
498 "corruption){0}"); | 498 "corruption){0}"); |
499 | 499 |
500 base::debug::Alias(buf); | 500 base::debug::Alias(buf); |
501 } | 501 } |
502 #endif // !defined(ADDRESS_SANITIZER) | 502 #endif // !defined(ADDRESS_SANITIZER) |
503 | 503 |
504 TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) { | 504 TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) { |
505 // Assert that freeing an unallocated pointer will crash the process. | 505 // Assert that freeing an unallocated pointer will crash the process. |
506 char buf[3]; | 506 char buf[3]; |
507 asm("" : "=r" (buf)); // Prevent clang from being too smart. | |
Mark Mentovai
2012/07/28 02:09:25
OK
| |
507 #if !defined(ADDRESS_SANITIZER) | 508 #if !defined(ADDRESS_SANITIZER) |
508 ASSERT_DEATH(free(buf), "being freed.*" | 509 ASSERT_DEATH(free(buf), "being freed.*" |
509 "\\*\\*\\* set a breakpoint in malloc_error_break to debug.*" | 510 "\\*\\*\\* set a breakpoint in malloc_error_break to debug.*" |
510 "Terminating process due to a potential for future heap corruption"); | 511 "Terminating process due to a potential for future heap corruption"); |
511 #else | 512 #else |
512 // AddressSanitizer replaces malloc() and prints a different error message on | 513 // AddressSanitizer replaces malloc() and prints a different error message on |
513 // heap corruption. | 514 // heap corruption. |
514 ASSERT_DEATH(free(buf), "attempting free on address which " | 515 ASSERT_DEATH(free(buf), "attempting free on address which " |
515 "was not malloc\\(\\)-ed"); | 516 "was not malloc\\(\\)-ed"); |
516 #endif // !defined(ADDRESS_SANITIZER) | 517 #endif // !defined(ADDRESS_SANITIZER) |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1206 SetUpInDeathAssert(); | 1207 SetUpInDeathAssert(); |
1207 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} | 1208 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} |
1208 }, ""); | 1209 }, ""); |
1209 } | 1210 } |
1210 | 1211 |
1211 #endif // !ARCH_CPU_64_BITS | 1212 #endif // !ARCH_CPU_64_BITS |
1212 #endif // OS_MACOSX | 1213 #endif // OS_MACOSX |
1213 | 1214 |
1214 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && | 1215 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && |
1215 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) | 1216 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) |
OLD | NEW |