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

Side by Side Diff: util/win/exception_handler_server.cc

Issue 1326443007: win: Fix incorrect thread suspend count due to ScopedProcessSuspend (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: pass in state Created 5 years, 3 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
« snapshot/win/process_reader_win.cc ('K') | « tools/generate_dump.cc ('k') | no next file » | 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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/win/exception_handler_server.h" 15 #include "util/win/exception_handler_server.h"
16 16
17 #include <string.h> 17 #include <string.h>
18 18
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/rand_util.h" 20 #include "base/rand_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "minidump/minidump_file_writer.h" 23 #include "minidump/minidump_file_writer.h"
24 #include "snapshot/crashpad_info_client_options.h" 24 #include "snapshot/crashpad_info_client_options.h"
25 #include "snapshot/win/process_snapshot_win.h" 25 #include "snapshot/win/process_snapshot_win.h"
26 #include "util/file/file_writer.h" 26 #include "util/file/file_writer.h"
27 #include "util/misc/tri_state.h" 27 #include "util/misc/tri_state.h"
28 #include "util/misc/uuid.h" 28 #include "util/misc/uuid.h"
29 #include "util/win/registration_protocol_win.h" 29 #include "util/win/registration_protocol_win.h"
30 #include "util/win/scoped_process_suspend.h"
30 31
31 namespace crashpad { 32 namespace crashpad {
32 33
33 namespace { 34 namespace {
34 35
35 decltype(GetNamedPipeClientProcessId)* GetNamedPipeClientProcessIdFunction() { 36 decltype(GetNamedPipeClientProcessId)* GetNamedPipeClientProcessIdFunction() {
36 static decltype(GetNamedPipeClientProcessId)* func = 37 static decltype(GetNamedPipeClientProcessId)* func =
37 reinterpret_cast<decltype(GetNamedPipeClientProcessId)*>(GetProcAddress( 38 reinterpret_cast<decltype(GetNamedPipeClientProcessId)*>(GetProcAddress(
38 GetModuleHandle(L"kernel32.dll"), "GetNamedPipeClientProcessId")); 39 GetModuleHandle(L"kernel32.dll"), "GetNamedPipeClientProcessId"));
39 return func; 40 return func;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 402
402 return 0; 403 return 0;
403 } 404 }
404 405
405 // static 406 // static
406 void __stdcall ExceptionHandlerServer::OnDumpEvent(void* ctx, BOOLEAN) { 407 void __stdcall ExceptionHandlerServer::OnDumpEvent(void* ctx, BOOLEAN) {
407 // This function is executed on the thread pool. 408 // This function is executed on the thread pool.
408 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); 409 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx);
409 base::AutoLock lock(*client->lock()); 410 base::AutoLock lock(*client->lock());
410 411
412 ScopedProcessSuspend suspend(client->process());
Mark Mentovai 2015/09/09 18:57:27 I think this worked better in CrashReportException
scottmg 2015/09/09 19:13:25 OK, done.
413
411 // Capture the exception. 414 // Capture the exception.
412 unsigned int exit_code = client->delegate()->ExceptionHandlerServerException( 415 unsigned int exit_code = client->delegate()->ExceptionHandlerServerException(
413 client->process(), client->exception_information_address()); 416 client->process(), client->exception_information_address());
414 417
415 TerminateProcess(client->process(), exit_code); 418 TerminateProcess(client->process(), exit_code);
416 } 419 }
417 420
418 // static 421 // static
419 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { 422 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) {
420 // This function is executed on the thread pool. 423 // This function is executed on the thread pool.
421 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); 424 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx);
422 base::AutoLock lock(*client->lock()); 425 base::AutoLock lock(*client->lock());
423 426
424 // Post back to the main thread to have it delete this client record. 427 // Post back to the main thread to have it delete this client record.
425 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); 428 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr);
426 } 429 }
427 430
428 } // namespace crashpad 431 } // namespace crashpad
OLDNEW
« snapshot/win/process_reader_win.cc ('K') | « tools/generate_dump.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698