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

Side by Side Diff: handler/mac/crash_report_exception_handler.cc

Issue 1066243002: Accept non-fatal resource exceptions without generating crash reports (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Swallow non-fatal EXC_RESOURCE Created 5 years, 8 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
« no previous file with comments | « compat/mac/sys/resource.h ('k') | snapshot/mac/exception_snapshot_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 10 matching lines...) Expand all
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/mac/mach_logging.h" 22 #include "base/mac/mach_logging.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "client/settings.h" 24 #include "client/settings.h"
25 #include "minidump/minidump_file_writer.h" 25 #include "minidump/minidump_file_writer.h"
26 #include "snapshot/mac/crashpad_info_client_options.h" 26 #include "snapshot/mac/crashpad_info_client_options.h"
27 #include "snapshot/mac/process_snapshot_mac.h" 27 #include "snapshot/mac/process_snapshot_mac.h"
28 #include "util/file/file_writer.h" 28 #include "util/file/file_writer.h"
29 #include "util/mach/exc_client_variants.h" 29 #include "util/mach/exc_client_variants.h"
30 #include "util/mach/exception_behaviors.h" 30 #include "util/mach/exception_behaviors.h"
31 #include "util/mach/exception_types.h"
31 #include "util/mach/mach_extensions.h" 32 #include "util/mach/mach_extensions.h"
32 #include "util/mach/mach_message.h" 33 #include "util/mach/mach_message.h"
33 #include "util/mach/scoped_task_suspend.h" 34 #include "util/mach/scoped_task_suspend.h"
34 #include "util/mach/symbolic_constants_mach.h" 35 #include "util/mach/symbolic_constants_mach.h"
35 #include "util/misc/tri_state.h" 36 #include "util/misc/tri_state.h"
36 #include "util/misc/uuid.h" 37 #include "util/misc/uuid.h"
37 38
38 namespace crashpad { 39 namespace crashpad {
39 40
40 CrashReportExceptionHandler::CrashReportExceptionHandler( 41 CrashReportExceptionHandler::CrashReportExceptionHandler(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return KERN_FAILURE; 95 return KERN_FAILURE;
95 } 96 }
96 97
97 // Check for suspicious message sources. A suspicious exception message comes 98 // Check for suspicious message sources. A suspicious exception message comes
98 // from a source other than the kernel or the process that the exception 99 // from a source other than the kernel or the process that the exception
99 // purportedly occurred in. 100 // purportedly occurred in.
100 // 101 //
101 // TODO(mark): Consider exceptions outside of the range (0, 32) from the 102 // TODO(mark): Consider exceptions outside of the range (0, 32) from the
102 // kernel to be suspicious, and exceptions other than kMachExceptionSimulated 103 // kernel to be suspicious, and exceptions other than kMachExceptionSimulated
103 // from the process itself to be suspicious. 104 // from the process itself to be suspicious.
105 const pid_t pid = process_snapshot.ProcessID();
104 pid_t audit_pid = AuditPIDFromMachMessageTrailer(trailer); 106 pid_t audit_pid = AuditPIDFromMachMessageTrailer(trailer);
105 if (audit_pid != -1 && audit_pid != 0) { 107 if (audit_pid != -1 && audit_pid != 0) {
106 pid_t exception_pid = process_snapshot.ProcessID(); 108 if (audit_pid != pid) {
107 if (exception_pid != audit_pid) { 109 LOG(WARNING) << "exception for pid " << pid << " sent by pid "
108 LOG(WARNING) << "exception for pid " << exception_pid << " sent by pid "
109 << audit_pid; 110 << audit_pid;
110 } 111 }
111 } 112 }
112 113
114 if (IsExceptionNonfatalResource(exception, code[0], pid)) {
115 // Swallow non-fatal resource exceptions.
116 //
117 // Normally, all EXC_RESOURCE exceptions go to the host-level EXC_RESOURCE
118 // handler, com.apple.ReportCrash.root, which invokes spindump to handle
119 // them. These non-fatal exceptions are never user-visible and are not
120 // currently of interest to Crashpad. Returning success here gets the
121 // process going again quickly, without generating a crash report.
122 //
123 // Alternatively, this could return KERN_FAILURE to let the exception go to
124 // the host-level handler, but there doesn’t seem to be much value in doing
125 // so.
126 ExcServerCopyState(
127 behavior, old_state, old_state_count, new_state, new_state_count);
128 return ExcServerSuccessfulReturnValue(behavior, false);
129 }
130
113 CrashpadInfoClientOptions client_options; 131 CrashpadInfoClientOptions client_options;
114 process_snapshot.GetCrashpadOptions(&client_options); 132 process_snapshot.GetCrashpadOptions(&client_options);
115 133
116 if (client_options.crashpad_handler_behavior != TriState::kDisabled) { 134 if (client_options.crashpad_handler_behavior != TriState::kDisabled) {
117 if (!process_snapshot.InitializeException(behavior, 135 if (!process_snapshot.InitializeException(behavior,
118 thread, 136 thread,
119 exception, 137 exception,
120 code, 138 code,
121 code_count, 139 code_count,
122 *flavor, 140 *flavor,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 252
235 if (!forwarded) { 253 if (!forwarded) {
236 ExcServerCopyState( 254 ExcServerCopyState(
237 behavior, old_state, old_state_count, new_state, new_state_count); 255 behavior, old_state, old_state_count, new_state, new_state_count);
238 } 256 }
239 257
240 return ExcServerSuccessfulReturnValue(behavior, false); 258 return ExcServerSuccessfulReturnValue(behavior, false);
241 } 259 }
242 260
243 } // namespace crashpad 261 } // namespace crashpad
OLDNEW
« no previous file with comments | « compat/mac/sys/resource.h ('k') | snapshot/mac/exception_snapshot_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698