Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: base/process_util_unittest.cc

Issue 9597031: In CrMallocErrorBreak, do not kill the process if errno is ENOMEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/process_util_mac.mm ('K') | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_unittest.cc
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 5a72f19c65aa6b071ae6fda3448fde0627643481..ff3a6071253a30db567e655eaf4b8c5d301c2187 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -22,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>
@@ -39,6 +39,7 @@
#include <windows.h>
#endif
#if defined(OS_MACOSX)
+#include <cmath>
#include <malloc/malloc.h>
#include "base/process_util_unittest_mac.h"
#endif
@@ -454,8 +455,13 @@ TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) {
// test suite setup and does not need to be done again, else mach_override
// will fail.
- char buf[3];
- ASSERT_DEATH(free(buf), "being freed.*"
+ // Test that ENOMEM doesn't crash. "I just want to allocate 1 petabyte."
+ void* buf = malloc(pow(10, 15));
Scott Hess - ex-Googler 2012/03/05 20:34:20 This isn't really 32-bit safe, is it? It just hap
Robert Sesek 2012/03/06 01:16:27 Done in a C++ way.
+ EXPECT_FALSE(buf);
+ EXPECT_EQ(ENOMEM, errno) << "Expected no memory error";
Scott Hess - ex-Googler 2012/03/05 20:34:20 Is the death-test below considered proof enough th
Robert Sesek 2012/03/06 01:16:27 Yes.
+
+ char stack_buf[3];
+ ASSERT_DEATH(free(stack_buf), "being freed.*"
"\\*\\*\\* set a breakpoint in malloc_error_break to debug.*"
"Terminating process due to a potential for future heap corruption");
}
« base/process_util_mac.mm ('K') | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698