OLD | NEW |
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/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #endif | 52 #endif |
53 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
54 #include <windows.h> | 54 #include <windows.h> |
55 #include "base/win/windows_version.h" | 55 #include "base/win/windows_version.h" |
56 #endif | 56 #endif |
57 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
58 #include <mach/vm_param.h> | 58 #include <mach/vm_param.h> |
59 #include <malloc/malloc.h> | 59 #include <malloc/malloc.h> |
60 #include "base/mac/mac_util.h" | 60 #include "base/mac/mac_util.h" |
61 #endif | 61 #endif |
62 #if defined(OS_ANDROID) | |
63 #include "third_party/lss/linux_syscall_support.h" | |
64 #endif | |
65 | 62 |
66 using base::FilePath; | 63 using base::FilePath; |
67 | 64 |
68 namespace { | 65 namespace { |
69 | 66 |
70 const char kSignalFileSlow[] = "SlowChildProcess.die"; | 67 const char kSignalFileSlow[] = "SlowChildProcess.die"; |
71 const char kSignalFileKill[] = "KilledChildProcess.die"; | 68 const char kSignalFileKill[] = "KilledChildProcess.die"; |
72 | 69 |
73 #if defined(OS_POSIX) | 70 #if defined(OS_POSIX) |
74 const char kSignalFileTerm[] = "TerminatedChildProcess.die"; | 71 const char kSignalFileTerm[] = "TerminatedChildProcess.die"; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // symbol data for this unit test's executable before firing the | 219 // symbol data for this unit test's executable before firing the |
223 // signal handler. | 220 // signal handler. |
224 // | 221 // |
225 // TODO(gspencer): turn this test process into a very small program | 222 // TODO(gspencer): turn this test process into a very small program |
226 // with no symbols (instead of using the multiprocess testing | 223 // with no symbols (instead of using the multiprocess testing |
227 // framework) to reduce the ReportCrash overhead. | 224 // framework) to reduce the ReportCrash overhead. |
228 const char kSignalFileCrash[] = "CrashingChildProcess.die"; | 225 const char kSignalFileCrash[] = "CrashingChildProcess.die"; |
229 | 226 |
230 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { | 227 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { |
231 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); | 228 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); |
232 #if defined(OS_ANDROID) | 229 #if defined(OS_POSIX) |
233 // Android L+ expose signal and sigaction symbols that override the system | |
234 // ones. There is a bug in these functions where a request to set the handler | |
235 // to SIG_DFL is ignored. In that case, an infinite loop is entered as the | |
236 // signal is repeatedly sent to the crash dump signal handler. | |
237 // To work around this, directly call the system's sigaction. | |
238 struct kernel_sigaction sa; | |
239 memset(&sa, 0, sizeof(sa)); | |
240 sys_sigemptyset(&sa.sa_mask); | |
241 sa.sa_handler_ = SIG_DFL; | |
242 sa.sa_flags = SA_RESTART; | |
243 sys_rt_sigaction(SIGSEGV, &sa, NULL, sizeof(kernel_sigset_t)); | |
244 #elif defined(OS_POSIX) | |
245 // Have to disable to signal handler for segv so we can get a crash | 230 // Have to disable to signal handler for segv so we can get a crash |
246 // instead of an abnormal termination through the crash dump handler. | 231 // instead of an abnormal termination through the crash dump handler. |
247 ::signal(SIGSEGV, SIG_DFL); | 232 ::signal(SIGSEGV, SIG_DFL); |
248 #endif | 233 #endif |
249 // Make this process have a segmentation fault. | 234 // Make this process have a segmentation fault. |
250 volatile int* oops = NULL; | 235 volatile int* oops = NULL; |
251 *oops = 0xDEAD; | 236 *oops = 0xDEAD; |
252 return 1; | 237 return 1; |
253 } | 238 } |
254 | 239 |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 options.current_directory = base::FilePath("/dev/null"); | 1105 options.current_directory = base::FilePath("/dev/null"); |
1121 | 1106 |
1122 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); | 1107 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); |
1123 ASSERT_TRUE(process.IsValid()); | 1108 ASSERT_TRUE(process.IsValid()); |
1124 | 1109 |
1125 int exit_code = kSuccess; | 1110 int exit_code = kSuccess; |
1126 EXPECT_TRUE(process.WaitForExit(&exit_code)); | 1111 EXPECT_TRUE(process.WaitForExit(&exit_code)); |
1127 EXPECT_NE(kSuccess, exit_code); | 1112 EXPECT_NE(kSuccess, exit_code); |
1128 } | 1113 } |
1129 #endif | 1114 #endif |
OLD | NEW |