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

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: On 64 bit systems, pointers are large - doofus. 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.
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.
45 // Note that the return value is used in testing.
46 DWORD LaunchAndWaitForHandler(EXCEPTION_POINTERS* pointers);
47
48 private:
49 // A copy of the actual exception pointers made at time of exception.
50 EXCEPTION_POINTERS exception_pointers_;
51
52 // The precomputed startup info and command line for launching the fallback
53 // handler.
54 base::win::StartupInformation startup_info_;
55 // Stores the pre-cooked command line, with an allotment of zeros at the back
56 // sufficient for writing in the thread id, just before launch.
57 std::vector<wchar_t> cmd_line_;
58
59 // An inheritable handle to our own process, the raw handle is necessary
60 // for pre-computing the startup info.
61 base::win::ScopedHandle self_process_handle_;
62
63 DISALLOW_COPY_AND_ASSIGN(FallbackCrashHandlerLauncher);
64 };
65
66 } // namespace crash_reporter
67
68 #endif // COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_
OLDNEW
« no previous file with comments | « components/crash/content/app/BUILD.gn ('k') | components/crash/content/app/fallback_crash_handler_launcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698