2015-08-18 12:25:19 -07:00
|
|
|
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "snapshot/win/exception_snapshot_win.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
#include "base/files/file_path.h"
|
2015-08-18 12:25:19 -07:00
|
|
|
#include "base/strings/stringprintf.h"
|
2015-09-18 16:06:05 -07:00
|
|
|
#include "base/strings/string16.h"
|
2015-08-18 12:25:19 -07:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
|
#include "client/crashpad_client.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "snapshot/win/process_snapshot_win.h"
|
2015-09-18 16:06:05 -07:00
|
|
|
#include "test/paths.h"
|
2015-09-20 11:16:31 -07:00
|
|
|
#include "test/win/child_launcher.h"
|
|
|
|
#include "util/file/file_io.h"
|
2015-08-18 12:25:19 -07:00
|
|
|
#include "util/thread/thread.h"
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
#include "util/win/exception_handler_server.h"
|
|
|
|
#include "util/win/registration_protocol_win.h"
|
2015-08-18 12:25:19 -07:00
|
|
|
#include "util/win/scoped_handle.h"
|
2015-09-09 12:29:29 -07:00
|
|
|
#include "util/win/scoped_process_suspend.h"
|
2015-08-18 12:25:19 -07:00
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
HANDLE DuplicateEvent(HANDLE process, HANDLE event) {
|
|
|
|
HANDLE handle;
|
|
|
|
if (DuplicateHandle(GetCurrentProcess(),
|
|
|
|
event,
|
|
|
|
process,
|
|
|
|
&handle,
|
|
|
|
SYNCHRONIZE | EVENT_MODIFY_STATE,
|
|
|
|
false,
|
|
|
|
0)) {
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
class Delegate : public ExceptionHandlerServer::Delegate {
|
2015-08-18 12:25:19 -07:00
|
|
|
public:
|
2015-09-18 16:06:05 -07:00
|
|
|
Delegate(HANDLE server_ready, HANDLE completed_test_event)
|
|
|
|
: server_ready_(server_ready),
|
|
|
|
completed_test_event_(completed_test_event),
|
|
|
|
break_near_(0) {}
|
|
|
|
~Delegate() override {}
|
|
|
|
|
|
|
|
void set_break_near(WinVMAddress break_near) { break_near_ = break_near; }
|
|
|
|
|
|
|
|
void ExceptionHandlerServerStarted() override { SetEvent(server_ready_); }
|
|
|
|
|
|
|
|
unsigned int ExceptionHandlerServerException(
|
|
|
|
HANDLE process,
|
|
|
|
WinVMAddress exception_information_address) override {
|
|
|
|
ScopedProcessSuspend suspend(process);
|
|
|
|
ProcessSnapshotWin snapshot;
|
|
|
|
snapshot.Initialize(process, ProcessSuspensionState::kSuspended);
|
|
|
|
snapshot.InitializeException(exception_information_address);
|
|
|
|
|
|
|
|
// Confirm the exception record was read correctly.
|
|
|
|
EXPECT_NE(snapshot.Exception()->ThreadID(), 0u);
|
|
|
|
EXPECT_EQ(snapshot.Exception()->Exception(), EXCEPTION_BREAKPOINT);
|
|
|
|
|
|
|
|
// Verify the exception happened at the expected location with a bit of
|
|
|
|
// slop space to allow for reading the current PC before the exception
|
|
|
|
// happens. See CrashingChildProcess::Run().
|
|
|
|
const uint64_t kAllowedOffset = 64;
|
|
|
|
EXPECT_GT(snapshot.Exception()->ExceptionAddress(), break_near_);
|
|
|
|
EXPECT_LT(snapshot.Exception()->ExceptionAddress(),
|
|
|
|
break_near_ + kAllowedOffset);
|
|
|
|
|
|
|
|
SetEvent(completed_test_event_);
|
|
|
|
|
|
|
|
return snapshot.Exception()->Exception();
|
|
|
|
}
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
|
|
|
|
private:
|
2015-09-18 16:06:05 -07:00
|
|
|
HANDLE server_ready_; // weak
|
|
|
|
HANDLE completed_test_event_; // weak
|
|
|
|
WinVMAddress break_near_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Delegate);
|
2015-08-18 12:25:19 -07:00
|
|
|
};
|
|
|
|
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
// Runs the ExceptionHandlerServer on a background thread.
|
2015-08-18 12:25:19 -07:00
|
|
|
class RunServerThread : public Thread {
|
|
|
|
public:
|
2015-09-03 13:31:19 -07:00
|
|
|
// Instantiates a thread which will invoke server->Run(delegate, pipe_name);
|
|
|
|
RunServerThread(ExceptionHandlerServer* server,
|
|
|
|
ExceptionHandlerServer::Delegate* delegate,
|
|
|
|
const std::string& pipe_name)
|
|
|
|
: server_(server), delegate_(delegate), pipe_name_(pipe_name) {}
|
2015-08-18 12:25:19 -07:00
|
|
|
~RunServerThread() override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Thread:
|
2015-09-03 13:31:19 -07:00
|
|
|
void ThreadMain() override { server_->Run(delegate_, pipe_name_); }
|
2015-08-18 12:25:19 -07:00
|
|
|
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
ExceptionHandlerServer* server_;
|
2015-09-03 13:31:19 -07:00
|
|
|
ExceptionHandlerServer::Delegate* delegate_;
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
std::string pipe_name_;
|
2015-08-18 12:25:19 -07:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(RunServerThread);
|
|
|
|
};
|
|
|
|
|
|
|
|
// During destruction, ensures that the server is stopped and the background
|
|
|
|
// thread joined.
|
|
|
|
class ScopedStopServerAndJoinThread {
|
|
|
|
public:
|
2015-09-03 13:31:19 -07:00
|
|
|
ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread)
|
2015-08-18 12:25:19 -07:00
|
|
|
: server_(server), thread_(thread) {}
|
|
|
|
~ScopedStopServerAndJoinThread() {
|
|
|
|
server_->Stop();
|
|
|
|
thread_->Join();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
ExceptionHandlerServer* server_;
|
2015-08-18 12:25:19 -07:00
|
|
|
Thread* thread_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ScopedStopServerAndJoinThread);
|
|
|
|
};
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
void TestCrashingChild(const base::string16& directory_modification) {
|
2015-08-18 12:25:19 -07:00
|
|
|
// Set up the registration server on a background thread.
|
|
|
|
std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" +
|
|
|
|
base::StringPrintf("%08x", GetCurrentProcessId());
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr));
|
|
|
|
ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr));
|
|
|
|
Delegate delegate(server_ready.get(), completed.get());
|
|
|
|
|
2015-09-03 13:31:19 -07:00
|
|
|
ExceptionHandlerServer exception_handler_server;
|
|
|
|
RunServerThread server_thread(
|
|
|
|
&exception_handler_server, &delegate, pipe_name);
|
2015-08-18 12:25:19 -07:00
|
|
|
server_thread.Start();
|
|
|
|
ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
&exception_handler_server, &server_thread);
|
2015-08-18 12:25:19 -07:00
|
|
|
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
WaitForSingleObject(server_ready.get(), INFINITE);
|
2015-09-18 16:06:05 -07:00
|
|
|
|
|
|
|
// Spawn a child process, passing it the pipe name to connect to.
|
|
|
|
base::FilePath test_executable = Paths::Executable();
|
|
|
|
std::wstring child_test_executable =
|
|
|
|
test_executable.DirName()
|
|
|
|
.Append(directory_modification)
|
|
|
|
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
|
|
|
|
L"_crashing_child.exe")
|
|
|
|
.value();
|
2015-09-20 11:16:31 -07:00
|
|
|
ChildLauncher child(child_test_executable, base::UTF8ToUTF16(pipe_name));
|
|
|
|
child.Start();
|
2015-08-18 12:25:19 -07:00
|
|
|
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
// The child tells us (approximately) where it will crash.
|
2015-09-18 16:06:05 -07:00
|
|
|
WinVMAddress break_near_address;
|
2015-09-20 11:16:31 -07:00
|
|
|
LoggingReadFile(child.stdout_read_handle(),
|
|
|
|
&break_near_address,
|
|
|
|
sizeof(break_near_address));
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
delegate.set_break_near(break_near_address);
|
2015-08-18 12:25:19 -07:00
|
|
|
|
win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.
(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.
Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.
The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).
In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.
R=cpu@chromium.org, mark@chromium.org, jschuh@chromium.org
BUG=crashpad:1,crashpad:45
Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07:00
|
|
|
// Wait for the child to crash and the exception information to be validated.
|
|
|
|
WaitForSingleObject(completed.get(), INFINITE);
|
2015-08-18 12:25:19 -07:00
|
|
|
}
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
TEST(ExceptionSnapshotWinTest, ChildCrash) {
|
|
|
|
TestCrashingChild(FILE_PATH_LITERAL("."));
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(ARCH_CPU_64_BITS)
|
|
|
|
TEST(ExceptionSnapshotWinTest, ChildCrashWOW64) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
TestCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
|
|
|
|
#else
|
|
|
|
TestCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif // ARCH_CPU_64_BITS
|
|
|
|
|
2015-08-18 12:25:19 -07:00
|
|
|
} // namespace
|
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|