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"); |
} |