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 | |
62 | 65 |
63 using base::FilePath; | 66 using base::FilePath; |
64 | 67 |
65 namespace { | 68 namespace { |
66 | 69 |
67 const char kSignalFileSlow[] = "SlowChildProcess.die"; | 70 const char kSignalFileSlow[] = "SlowChildProcess.die"; |
68 const char kSignalFileKill[] = "KilledChildProcess.die"; | 71 const char kSignalFileKill[] = "KilledChildProcess.die"; |
69 | 72 |
70 #if defined(OS_POSIX) | 73 #if defined(OS_POSIX) |
71 const char kSignalFileTerm[] = "TerminatedChildProcess.die"; | 74 const char kSignalFileTerm[] = "TerminatedChildProcess.die"; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 // symbol data for this unit test's executable before firing the | 222 // symbol data for this unit test's executable before firing the |
220 // signal handler. | 223 // signal handler. |
221 // | 224 // |
222 // TODO(gspencer): turn this test process into a very small program | 225 // TODO(gspencer): turn this test process into a very small program |
223 // with no symbols (instead of using the multiprocess testing | 226 // with no symbols (instead of using the multiprocess testing |
224 // framework) to reduce the ReportCrash overhead. | 227 // framework) to reduce the ReportCrash overhead. |
225 const char kSignalFileCrash[] = "CrashingChildProcess.die"; | 228 const char kSignalFileCrash[] = "CrashingChildProcess.die"; |
226 | 229 |
227 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { | 230 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { |
228 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); | 231 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); |
229 #if defined(OS_POSIX) | |
230 // Have to disable to signal handler for segv so we can get a crash | 232 // Have to disable to signal handler for segv so we can get a crash |
231 // instead of an abnormal termination through the crash dump handler. | 233 // instead of an abnormal termination through the crash dump handler. |
Nico
2015/07/20 23:44:07
keep this with the ::signal call in the elif posix
| |
234 #if defined(OS_ANDROID) | |
235 // Android L+ expose signal and sigaction symbols that override the system | |
236 // ones. There is a bug in these functions where a request to set the handler | |
237 // to SIG_DFL is ignored. In that case, an infinite loop is entered as the | |
238 // signal is repeatedly sent to the crash dump signal handler. | |
239 // To work around this, directly call the system's sigaction. | |
Nico
2015/07/20 23:44:07
whaaaaaaaat that is horrible
Primiano Tucci (use gerrit)
2015/07/21 09:04:11
Yes, it is, but to the best of my knowledge this i
| |
240 struct kernel_sigaction sa; | |
241 memset(&sa, 0, sizeof(sa)); | |
242 sys_sigemptyset(&sa.sa_mask); | |
243 sa.sa_handler_ = SIG_DFL; | |
244 sa.sa_flags = SA_RESTART; | |
245 sys_rt_sigaction(SIGSEGV, &sa, NULL, sizeof(kernel_sigset_t)); | |
246 #elif defined(OS_POSIX) | |
232 ::signal(SIGSEGV, SIG_DFL); | 247 ::signal(SIGSEGV, SIG_DFL); |
233 #endif | 248 #endif |
234 // Make this process have a segmentation fault. | 249 // Make this process have a segmentation fault. |
235 volatile int* oops = NULL; | 250 volatile int* oops = NULL; |
236 *oops = 0xDEAD; | 251 *oops = 0xDEAD; |
237 return 1; | 252 return 1; |
238 } | 253 } |
239 | 254 |
240 // This test intentionally crashes, so we don't need to run it under | 255 // This test intentionally crashes, so we don't need to run it under |
241 // AddressSanitizer. | 256 // AddressSanitizer. |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 options.current_directory = base::FilePath("/dev/null"); | 1120 options.current_directory = base::FilePath("/dev/null"); |
1106 | 1121 |
1107 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); | 1122 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); |
1108 ASSERT_TRUE(process.IsValid()); | 1123 ASSERT_TRUE(process.IsValid()); |
1109 | 1124 |
1110 int exit_code = kSuccess; | 1125 int exit_code = kSuccess; |
1111 EXPECT_TRUE(process.WaitForExit(&exit_code)); | 1126 EXPECT_TRUE(process.WaitForExit(&exit_code)); |
1112 EXPECT_NE(kSuccess, exit_code); | 1127 EXPECT_NE(kSuccess, exit_code); |
1113 } | 1128 } |
1114 #endif | 1129 #endif |
OLD | NEW |