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

Side by Side Diff: client/crashpad_client_win.cc

Issue 1464473003: win: Don't duplicate handles in handle restriction list (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 1 month 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (handle && handle != INVALID_HANDLE_VALUE) {
146 handle_list->push_back(handle); 147 // There doesn't seem to be any documentation of this, but if there's a
148 // handle duplicated in this list, CreateProcess() fails with
149 // ERROR_INVALID_PARAMETER.
150 if (std::find(handle_list->begin(), handle_list->end(), handle) ==
151 handle_list->end()) {
152 handle_list->push_back(handle);
153 }
147 } 154 }
148 } 155 }
149 156
150 } // namespace 157 } // namespace
151 158
152 namespace crashpad { 159 namespace crashpad {
153 160
154 CrashpadClient::CrashpadClient() 161 CrashpadClient::CrashpadClient()
155 : ipc_pipe_() { 162 : ipc_pipe_() {
156 } 163 }
157 164
158 CrashpadClient::~CrashpadClient() { 165 CrashpadClient::~CrashpadClient() {
166 g_signal_exception = INVALID_HANDLE_VALUE;
Mark Mentovai 2015/11/19 19:00:19 Not so sure about this. The intention was that you
scottmg 2015/11/19 19:15:49 OK. We do have one soft request for being able to
Mark Mentovai 2015/11/19 19:20:57 scottmg wrote:
scottmg 2015/11/19 19:25:33 Sounds good.
167 g_signal_non_crash_dump = INVALID_HANDLE_VALUE;
168 g_non_crash_dump_done = INVALID_HANDLE_VALUE;
169 g_critical_section_with_debug_info.DebugInfo = nullptr;
170
171 delete g_non_crash_dump_lock;
172 g_non_crash_dump_lock = nullptr;
159 } 173 }
160 174
161 bool CrashpadClient::StartHandler( 175 bool CrashpadClient::StartHandler(
162 const base::FilePath& handler, 176 const base::FilePath& handler,
163 const base::FilePath& database, 177 const base::FilePath& database,
164 const std::string& url, 178 const std::string& url,
165 const std::map<std::string, std::string>& annotations, 179 const std::map<std::string, std::string>& annotations,
166 const std::vector<std::string>& arguments, 180 const std::vector<std::string>& arguments,
167 bool restartable) { 181 bool restartable) {
168 DCHECK(ipc_pipe_.empty()); 182 DCHECK(ipc_pipe_.empty());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 DCHECK(!ipc_pipe_.empty()); 344 DCHECK(!ipc_pipe_.empty());
331 return ipc_pipe_; 345 return ipc_pipe_;
332 } 346 }
333 347
334 bool CrashpadClient::UseHandler() { 348 bool CrashpadClient::UseHandler() {
335 DCHECK(!ipc_pipe_.empty()); 349 DCHECK(!ipc_pipe_.empty());
336 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); 350 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE);
337 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); 351 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE);
338 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); 352 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE);
339 DCHECK(!g_critical_section_with_debug_info.DebugInfo); 353 DCHECK(!g_critical_section_with_debug_info.DebugInfo);
354 DCHECK(!g_non_crash_dump_lock);
340 355
341 ClientToServerMessage message; 356 ClientToServerMessage message;
342 memset(&message, 0, sizeof(message)); 357 memset(&message, 0, sizeof(message));
343 message.type = ClientToServerMessage::kRegister; 358 message.type = ClientToServerMessage::kRegister;
344 message.registration.version = RegistrationRequest::kMessageVersion; 359 message.registration.version = RegistrationRequest::kMessageVersion;
345 message.registration.client_process_id = GetCurrentProcessId(); 360 message.registration.client_process_id = GetCurrentProcessId();
346 message.registration.crash_exception_information = 361 message.registration.crash_exception_information =
347 reinterpret_cast<WinVMAddress>(&g_crash_exception_information); 362 reinterpret_cast<WinVMAddress>(&g_crash_exception_information);
348 message.registration.non_crash_exception_information = 363 message.registration.non_crash_exception_information =
349 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information); 364 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); 449 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE);
435 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; 450 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject";
436 } 451 }
437 452
438 // static 453 // static
439 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) { 454 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) {
440 UnhandledExceptionHandler(exception_pointers); 455 UnhandledExceptionHandler(exception_pointers);
441 } 456 }
442 457
443 } // namespace crashpad 458 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698