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

Side by Side Diff: components/crash/content/app/fallback_crash_handler_launcher_win.h

Issue 2596463002: A simple, practically zero cost fallback crash handler for Crashpad handler process. (Closed)
Patch Set: Fix Clank comparison nit. Created 3 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_
6 #define COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_
7
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/macros.h"
11 #include "base/win/scoped_handle.h"
12 #include "base/win/startup_information.h"
13
14 #include <windows.h>
15
16 namespace crash_reporter {
17
18 // This class is a last-ditch crash handler for the Crashpad handler process.
19 // It prepares and stores a command line, ready for dispatching when
20 // an exception occurs. Everything needed to call CreateProcess is pre-allocated
21 // to minimize the odds of re-faulting due to e.g. tripping over the same issue
22 // that caused the initial crash.
23 // This is still very much best-effort, as doing anything at all inside a
24 // process that's crashed is always going to be iffy^2.
25 class FallbackCrashHandlerLauncher {
26 public:
27 FallbackCrashHandlerLauncher();
28 ~FallbackCrashHandlerLauncher();
29
30 // Initializes everything that's needed in LaunchAndWaitforHandler.
scottmg 2017/01/09 21:10:56 ...Waitfor... -> ...WaitFor...
Sigurður Ásgeirsson 2017/01/09 21:30:38 Done.
31 bool Initialize(const base::CommandLine& program,
32 const base::FilePath& crashpad_database);
33
34 // Launch the pre-computed command line for the fallback error handler.
35 // The expectation is that this function will never return, as the fallback
36 // error handler should terminate it with the exception code as the process
37 // exit code. The return value from this function is therefore academic in
38 // the normal case.
39 // However, for completeness, this function returns one of:
40 // - The error from CreateProcess if it fails to launch the fallback handler.
41 // - The error from waiting on the fallback crash handler process if it
42 // fails to wait for that process to exit.
43 // - The exit code from the fallback crash handler process.
44 // - The error encountered in retrieving the crash handler process' exit code.
scottmg 2017/01/09 21:10:56 Note here that the return path is used by test cod
Sigurður Ásgeirsson 2017/01/09 21:30:38 Done.
45 DWORD LaunchAndWaitForHandler(EXCEPTION_POINTERS* pointers);
46
47 private:
48 // A copy of the actual exception pointers made at time of exception.
49 EXCEPTION_POINTERS exception_pointers_;
50
51 // The precomputed startup info and command line for launching the fallback
52 // handler.
53 base::win::StartupInformation startup_info_;
54 // Stores the pre-cooked command line, with an allotment of zeros at the back
55 // sufficient for writing in the thread id, just before launch.
56 std::vector<wchar_t> cmd_line_;
57
58 // An inheritable handle to our own process, the raw handle is necessary
59 // for pre-computing the startup info.
60 base::win::ScopedHandle self_process_handle_;
61
62 DISALLOW_COPY_AND_ASSIGN(FallbackCrashHandlerLauncher);
63 };
64
65 } // namespace crash_reporter
66
67 #endif // COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698