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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/process_util.h" 15 #include "base/process_util.h"
16 #include "base/test/multiprocess_test.h" 16 #include "base/test/multiprocess_test.h"
17 #include "base/test/test_timeouts.h" 17 #include "base/test/test_timeouts.h"
18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
19 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/multiprocess_func_list.h" 22 #include "testing/multiprocess_func_list.h"
23 23
24 #if defined(OS_LINUX) 24 #if defined(OS_LINUX)
25 #include <errno.h>
26 #include <malloc.h> 25 #include <malloc.h>
27 #include <glib.h> 26 #include <glib.h>
28 #include <sched.h> 27 #include <sched.h>
29 #endif 28 #endif
30 #if defined(OS_POSIX) 29 #if defined(OS_POSIX)
30 #include <errno.h>
31 #include <dlfcn.h> 31 #include <dlfcn.h>
32 #include <fcntl.h> 32 #include <fcntl.h>
33 #include <signal.h> 33 #include <signal.h>
34 #include <sys/resource.h> 34 #include <sys/resource.h>
35 #include <sys/socket.h> 35 #include <sys/socket.h>
36 #include <sys/wait.h> 36 #include <sys/wait.h>
37 #endif 37 #endif
38 #if defined(OS_WIN) 38 #if defined(OS_WIN)
39 #include <windows.h> 39 #include <windows.h>
40 #endif 40 #endif
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 #endif // defined(OS_WIN) 448 #endif // defined(OS_WIN)
449 449
450 #if defined(OS_MACOSX) 450 #if defined(OS_MACOSX)
451 451
452 TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) { 452 TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) {
453 // Note that base::EnableTerminationOnHeapCorruption() is called as part of 453 // Note that base::EnableTerminationOnHeapCorruption() is called as part of
454 // test suite setup and does not need to be done again, else mach_override 454 // test suite setup and does not need to be done again, else mach_override
455 // will fail. 455 // will fail.
456 456
457 char buf[3]; 457 // Test that ENOMEM doesn't crash.
458 ASSERT_DEATH(free(buf), "being freed.*" 458 void* buf = malloc(std::numeric_limits<size_t>::max());
Scott Hess - ex-Googler 2012/03/06 01:27:51 Whoa, that's super shiny! BTW, did you see the co
Robert Sesek 2012/03/06 01:55:43 Very, very relevant. That explains the behavior I
459 EXPECT_FALSE(buf);
460 EXPECT_EQ(ENOMEM, errno) << "Expected no memory error";
461
462 char stack_buf[3];
463 ASSERT_DEATH(free(stack_buf), "being freed.*"
459 "\\*\\*\\* set a breakpoint in malloc_error_break to debug.*" 464 "\\*\\*\\* set a breakpoint in malloc_error_break to debug.*"
460 "Terminating process due to a potential for future heap corruption"); 465 "Terminating process due to a potential for future heap corruption");
461 } 466 }
462 467
463 #endif // defined(OS_MACOSX) 468 #endif // defined(OS_MACOSX)
464 469
465 #if defined(OS_POSIX) 470 #if defined(OS_POSIX)
466 471
467 namespace { 472 namespace {
468 473
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 SetUpInDeathAssert(); 1155 SetUpInDeathAssert();
1151 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} 1156 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {}
1152 }, ""); 1157 }, "");
1153 } 1158 }
1154 1159
1155 #endif // !ARCH_CPU_64_BITS 1160 #endif // !ARCH_CPU_64_BITS
1156 #endif // OS_MACOSX 1161 #endif // OS_MACOSX
1157 1162
1158 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && 1163 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) &&
1159 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) 1164 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER)
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698