OLD | NEW |
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 static const auto delete_proc_thread_attribute_list = | 125 static const auto delete_proc_thread_attribute_list = |
126 GET_FUNCTION_REQUIRED(L"kernel32.dll", ::DeleteProcThreadAttributeList); | 126 GET_FUNCTION_REQUIRED(L"kernel32.dll", ::DeleteProcThreadAttributeList); |
127 delete_proc_thread_attribute_list(proc_thread_attribute_list); | 127 delete_proc_thread_attribute_list(proc_thread_attribute_list); |
128 } | 128 } |
129 }; | 129 }; |
130 | 130 |
131 using ScopedProcThreadAttributeList = | 131 using ScopedProcThreadAttributeList = |
132 base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, | 132 base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, |
133 ScopedProcThreadAttributeListTraits>; | 133 ScopedProcThreadAttributeListTraits>; |
134 | 134 |
135 // Adds |handle| to |handle_list| if it appears valid. | 135 // Adds |handle| to |handle_list| if it appears valid, and is not already in |
| 136 // |handle_list|. |
136 // | 137 // |
137 // Invalid handles (including INVALID_HANDLE_VALUE and null handles) cannot be | 138 // Invalid handles (including INVALID_HANDLE_VALUE and null handles) cannot be |
138 // added to a PPROC_THREAD_ATTRIBUTE_LIST’s PROC_THREAD_ATTRIBUTE_HANDLE_LIST. | 139 // added to a PPROC_THREAD_ATTRIBUTE_LIST’s PROC_THREAD_ATTRIBUTE_HANDLE_LIST. |
139 // If INVALID_HANDLE_VALUE appears, CreateProcess() will fail with | 140 // If INVALID_HANDLE_VALUE appears, CreateProcess() will fail with |
140 // ERROR_INVALID_PARAMETER. If a null handle appears, the child process will | 141 // ERROR_INVALID_PARAMETER. If a null handle appears, the child process will |
141 // silently not inherit any handles. | 142 // silently not inherit any handles. |
142 // | 143 // |
143 // Use this function to add handles with uncertain validities. | 144 // Use this function to add handles with uncertain validities. |
144 void AddHandleToListIfValid(std::vector<HANDLE>* handle_list, HANDLE handle) { | 145 void AddHandleToListIfValid(std::vector<HANDLE>* handle_list, HANDLE handle) { |
145 if (handle && handle != INVALID_HANDLE_VALUE) { | 146 // There doesn't seem to be any documentation of this, but if there's a handle |
| 147 // duplicated in this list, CreateProcess() fails with |
| 148 // ERROR_INVALID_PARAMETER. |
| 149 if (handle && handle != INVALID_HANDLE_VALUE && |
| 150 std::find(handle_list->begin(), handle_list->end(), handle) == |
| 151 handle_list->end()) { |
146 handle_list->push_back(handle); | 152 handle_list->push_back(handle); |
147 } | 153 } |
148 } | 154 } |
149 | 155 |
150 } // namespace | 156 } // namespace |
151 | 157 |
152 namespace crashpad { | 158 namespace crashpad { |
153 | 159 |
154 CrashpadClient::CrashpadClient() | 160 CrashpadClient::CrashpadClient() |
155 : ipc_pipe_() { | 161 : ipc_pipe_() { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 DCHECK(!ipc_pipe_.empty()); | 336 DCHECK(!ipc_pipe_.empty()); |
331 return ipc_pipe_; | 337 return ipc_pipe_; |
332 } | 338 } |
333 | 339 |
334 bool CrashpadClient::UseHandler() { | 340 bool CrashpadClient::UseHandler() { |
335 DCHECK(!ipc_pipe_.empty()); | 341 DCHECK(!ipc_pipe_.empty()); |
336 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); | 342 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); |
337 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); | 343 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); |
338 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); | 344 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); |
339 DCHECK(!g_critical_section_with_debug_info.DebugInfo); | 345 DCHECK(!g_critical_section_with_debug_info.DebugInfo); |
| 346 DCHECK(!g_non_crash_dump_lock); |
340 | 347 |
341 ClientToServerMessage message; | 348 ClientToServerMessage message; |
342 memset(&message, 0, sizeof(message)); | 349 memset(&message, 0, sizeof(message)); |
343 message.type = ClientToServerMessage::kRegister; | 350 message.type = ClientToServerMessage::kRegister; |
344 message.registration.version = RegistrationRequest::kMessageVersion; | 351 message.registration.version = RegistrationRequest::kMessageVersion; |
345 message.registration.client_process_id = GetCurrentProcessId(); | 352 message.registration.client_process_id = GetCurrentProcessId(); |
346 message.registration.crash_exception_information = | 353 message.registration.crash_exception_information = |
347 reinterpret_cast<WinVMAddress>(&g_crash_exception_information); | 354 reinterpret_cast<WinVMAddress>(&g_crash_exception_information); |
348 message.registration.non_crash_exception_information = | 355 message.registration.non_crash_exception_information = |
349 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information); | 356 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); | 441 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); |
435 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; | 442 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; |
436 } | 443 } |
437 | 444 |
438 // static | 445 // static |
439 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) { | 446 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) { |
440 UnhandledExceptionHandler(exception_pointers); | 447 UnhandledExceptionHandler(exception_pointers); |
441 } | 448 } |
442 | 449 |
443 } // namespace crashpad | 450 } // namespace crashpad |
OLD | NEW |