Commit 68ce7e28 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Fix use of base::debug::Alias in scoped_handle.cc

base::debug::Alias can only reliably trick the compiler into retaining
the values of local variables, not class member variables. Therefore it
is important to copy class member variables to locals before aliasing
them.

Bug: 756589
Change-Id: I5c67f386c2a6ad192af74fd9aefbc9103b355774
Reviewed-on: https://chromium-review.googlesource.com/792297Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519531}
parent fb1a8eac
......@@ -196,7 +196,8 @@ void ActiveVerifier::StartTracking(HANDLE handle, const void* owner,
if (!result.second) {
Info other = result.first->second;
base::debug::Alias(&other);
base::debug::Alias(&creation_stack_);
auto creation_stack = creation_stack_;
base::debug::Alias(&creation_stack);
CHECK(false); // Attempt to start tracking already tracked handle.
}
}
......@@ -209,14 +210,16 @@ void ActiveVerifier::StopTracking(HANDLE handle, const void* owner,
AutoNativeLock lock(*lock_);
HandleMap::iterator i = map_.find(handle);
if (i == map_.end()) {
base::debug::Alias(&creation_stack_);
auto creation_stack = creation_stack_;
base::debug::Alias(&creation_stack);
CHECK(false); // Attempting to close an untracked handle.
}
Info other = i->second;
if (other.owner != owner) {
base::debug::Alias(&other);
base::debug::Alias(&creation_stack_);
auto creation_stack = creation_stack_;
base::debug::Alias(&creation_stack);
CHECK(false); // Attempting to close a handle not owned by opener.
}
......@@ -241,7 +244,8 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) {
Info other = i->second;
base::debug::Alias(&other);
base::debug::Alias(&creation_stack_);
auto creation_stack = creation_stack_;
base::debug::Alias(&creation_stack);
CHECK(false); // CloseHandle called on tracked handle.
}
......
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