Commit b7a9aeeb authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] CHECK on OpenThread result

The failure of OpenThread to return a valid handle is the suspected
cause of the crash in the associated bug. This check is intended to
validate that suspicion.

Bug: 947459
Change-Id: I55e59bf903e5383d9def56c3c57f3b8b4de5182f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600315
Auto-Submit: Mike Wittman <wittman@chromium.org>
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Reviewed-by: default avatarCharlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657749}
parent 423db36a
......@@ -7,6 +7,7 @@
#include <windows.h>
#include <winternl.h>
#include "base/logging.h"
#include "base/profiler/native_unwinder_win.h"
#include "build/build_config.h"
......@@ -27,6 +28,14 @@ struct TEB {
// Rest of struct is ignored.
};
win::ScopedHandle GetThreadHandle(PlatformThreadId thread_id) {
win::ScopedHandle handle(::OpenThread(
THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION,
FALSE, thread_id));
CHECK(handle.IsValid());
return handle;
}
// Returns the thread environment block pointer for |thread_handle|.
const TEB* GetThreadEnvironmentBlock(HANDLE thread_handle) {
// Define the internal types we need to invoke NtQueryInformationThread.
......@@ -148,10 +157,7 @@ bool ThreadDelegateWin::ScopedSuspendThread::WasSuccessful() const {
// ThreadDelegateWin ----------------------------------------------------------
ThreadDelegateWin::ThreadDelegateWin(PlatformThreadId thread_id)
: thread_handle_(::OpenThread(
THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION,
FALSE,
thread_id)),
: thread_handle_(GetThreadHandle(thread_id)),
thread_stack_base_address_(reinterpret_cast<uintptr_t>(
GetThreadEnvironmentBlock(thread_handle_.Get())->Tib.StackBase)) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment