summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 21:56:17 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 21:56:17 +0000
commit7367fa3b70b65687d4e5d7f40ea3d973eb73c709 (patch)
tree97337321c35a74101a4c456c372e0543bc10f3d1
parente615e9c86e3d95fd4def087afe884d3c9229031c (diff)
downloadchromium_src-7367fa3b70b65687d4e5d7f40ea3d973eb73c709.zip
chromium_src-7367fa3b70b65687d4e5d7f40ea3d973eb73c709.tar.gz
chromium_src-7367fa3b70b65687d4e5d7f40ea3d973eb73c709.tar.bz2
Revert 125441 - In CrMallocErrorBreak, do not kill the process if errno is ENOMEM.
[Caused test failures on 10.5.] This will allow large JPEG decodes to be handled and optionally killed by the OOM killer instead. Based on a sampling of the other malloc_error_break() bugs ("unaligned pointer", "freed was not allocated", "double free", and "incorrect checksum"), this will only affect the "allocate region" error, as those others happen at free(), rather than malloc(). BUG=103980 TEST=Covered by ProcessUtilTest.MacTerminateOnHeapCorruption Review URL: http://codereview.chromium.org/9597031 TBR=rsesek@chromium.org Review URL: https://chromiumcodereview.appspot.com/9622023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125464 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process_util_mac.mm9
-rw-r--r--base/process_util_unittest.cc28
2 files changed, 6 insertions, 31 deletions
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm
index 6999cb5..6b39a61 100644
--- a/base/process_util_mac.mm
+++ b/base/process_util_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -549,13 +549,6 @@ malloc_error_break_t LookUpMallocErrorBreak() {
void CrMallocErrorBreak() {
g_original_malloc_error_break();
-
- // Out of memory is certainly not heap corruption, and not necessarily
- // something for which the process should be terminated. Leave that decision
- // to the OOM killer.
- if (errno == ENOMEM)
- return;
-
// A unit test checks this error message, so it needs to be in release builds.
LOG(ERROR) <<
"Terminating process due to a potential for future heap corruption";
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 771a587..d65b5e0 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -7,7 +7,6 @@
#include <limits>
#include "base/command_line.h"
-#include "base/debug/alias.h"
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
#include "base/logging.h"
@@ -23,12 +22,12 @@
#include "testing/multiprocess_func_list.h"
#if defined(OS_LINUX)
+#include <errno.h>
#include <malloc.h>
#include <glib.h>
#include <sched.h>
#endif
#if defined(OS_POSIX)
-#include <errno.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <signal.h>
@@ -40,7 +39,6 @@
#include <windows.h>
#endif
#if defined(OS_MACOSX)
-#include <mach/vm_param.h>
#include <malloc/malloc.h>
#include "base/process_util_unittest_mac.h"
#endif
@@ -451,27 +449,11 @@ TEST_F(ProcessUtilTest, LaunchAsUser) {
#if defined(OS_MACOSX)
-// For the following Mac tests:
-// Note that base::EnableTerminationOnHeapCorruption() is called as part of
-// test suite setup and does not need to be done again, else mach_override
-// will fail.
-
-TEST_F(ProcessUtilTest, MacMallocFailureDoesNotTerminate) {
- // Test that ENOMEM doesn't crash. The number of bytes is one less than
- // MALLOC_ABSOLUTE_MAX_SIZE, above which the system early-returns NULL and
- // does not call through malloc_error_break(). See the comment at
- // EnableTerminationOnOutOfMemory() for more information.
- void* buf = malloc(std::numeric_limits<size_t>::max() - (2 * PAGE_SIZE) - 1);
-
- // The optimizer can be too efficient in Release mode, so alias the value.
- base::debug::Alias(buf);
-
- EXPECT_FALSE(buf);
- EXPECT_EQ(ENOMEM, errno);
-}
-
TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) {
- // Assert that freeing an unallocated pointer will crash the process.
+ // Note that base::EnableTerminationOnHeapCorruption() is called as part of
+ // test suite setup and does not need to be done again, else mach_override
+ // will fail.
+
char buf[3];
#ifndef ADDRESS_SANITIZER
ASSERT_DEATH(free(buf), "being freed.*"