OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <crt_externs.h> | 8 #include <crt_externs.h> |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <errno.h> | 10 #include <errno.h> |
11 #include <mach/mach.h> | 11 #include <mach/mach.h> |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 reference_addr += nl[0].n_value; | 542 reference_addr += nl[0].n_value; |
543 | 543 |
544 return reinterpret_cast<malloc_error_break_t>(reference_addr); | 544 return reinterpret_cast<malloc_error_break_t>(reference_addr); |
545 #endif // ARCH_CPU_32_BITS | 545 #endif // ARCH_CPU_32_BITS |
546 | 546 |
547 return NULL; | 547 return NULL; |
548 } | 548 } |
549 | 549 |
550 void CrMallocErrorBreak() { | 550 void CrMallocErrorBreak() { |
551 g_original_malloc_error_break(); | 551 g_original_malloc_error_break(); |
552 | |
553 // Out of memory is certainly not heap corruption, and not necessarily | |
554 // something for which the process should be terminated. Leave that decision | |
555 // to the OOM killer. | |
556 if (errno == ENOMEM) | |
557 return; | |
558 | |
559 // A unit test checks this error message, so it needs to be in release builds. | 552 // A unit test checks this error message, so it needs to be in release builds. |
560 LOG(ERROR) << | 553 LOG(ERROR) << |
561 "Terminating process due to a potential for future heap corruption"; | 554 "Terminating process due to a potential for future heap corruption"; |
562 int* death_ptr = NULL; | 555 int* death_ptr = NULL; |
563 *death_ptr = 0xf00bad; | 556 *death_ptr = 0xf00bad; |
564 } | 557 } |
565 | 558 |
566 } // namespace | 559 } // namespace |
567 | 560 |
568 void EnableTerminationOnHeapCorruption() { | 561 void EnableTerminationOnHeapCorruption() { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 } | 1143 } |
1151 } | 1144 } |
1152 | 1145 |
1153 } // namespace | 1146 } // namespace |
1154 | 1147 |
1155 void EnsureProcessTerminated(ProcessHandle process) { | 1148 void EnsureProcessTerminated(ProcessHandle process) { |
1156 WaitForChildToDie(process, kWaitBeforeKillSeconds); | 1149 WaitForChildToDie(process, kWaitBeforeKillSeconds); |
1157 } | 1150 } |
1158 | 1151 |
1159 } // namespace base | 1152 } // namespace base |
OLD | NEW |