[go: up one dir, main page]

Remove HANDLE_FLAG_PROTECT_FROM_CLOSE flag from Tracked/ScopedHandle.

This reverts most of  https://crrev.com/c928d34ee861fd4102c352d9e79e1a4959a47209
(refs/heads/master@{#329516}).

There is a strong suspicion that this flag is causing a lot of extra crashes. In any
case, the change caused the handle verifier to be enabled for all channels, which was
not really intended (not desired).

BUG=475872
TBR=grt@chromium.org, wfh@chromium.org

Review URL: https://codereview.chromium.org/1355703002

Cr-Commit-Position: refs/heads/master@{#349531}
(cherry picked from commit 44c7a7ab481f11061bd398ce83eb43a0f549ce26)

Review URL: https://codereview.chromium.org/1357533003 .

Cr-Commit-Position: refs/branch-heads/2454@{#491}
Cr-Branched-From: 12bfc3360892ec53cd00fc239a47e5298beb063b-refs/heads/master@{#338390}
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc
index ce944e4..2ebef32 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -152,12 +152,6 @@
   if (!enabled_)
     return;
 
-  // Idea here is to make our handles non-closable until we close it ourselves.
-  // Handles provided could be totally fabricated especially through our
-  // unittest, we are ignoring that for now by not checking return value.
-  ::SetHandleInformation(handle, HANDLE_FLAG_PROTECT_FROM_CLOSE,
-                         HANDLE_FLAG_PROTECT_FROM_CLOSE);
-
   // Grab the thread id before the lock.
   DWORD thread_id = GetCurrentThreadId();
 
@@ -178,15 +172,6 @@
   if (!enabled_)
     return;
 
-  // We expect handle to be protected till this point.
-  DWORD flags = 0;
-  if (::GetHandleInformation(handle, &flags)) {
-    CHECK_NE(0U, (flags & HANDLE_FLAG_PROTECT_FROM_CLOSE));
-
-    // Unprotect handle so that it could be closed.
-    ::SetHandleInformation(handle, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0);
-  }
-
   AutoNativeLock lock(*lock_);
   HandleMap::iterator i = map_.find(handle);
   if (i == map_.end())
diff --git a/chrome/app/close_handle_hook_win.cc b/chrome/app/close_handle_hook_win.cc
index 4cdaf26..85cfce5a 100644
--- a/chrome/app/close_handle_hook_win.cc
+++ b/chrome/app/close_handle_hook_win.cc
@@ -185,8 +185,7 @@
 #elif defined(NDEBUG)
   chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
   if (channel == chrome::VersionInfo::CHANNEL_CANARY ||
-      channel == chrome::VersionInfo::CHANNEL_DEV ||
-      channel == chrome::VersionInfo::CHANNEL_UNKNOWN) {
+      channel == chrome::VersionInfo::CHANNEL_DEV) {
     return true;
   }
 
@@ -222,6 +221,8 @@
     // threads attempting to call CloseHandle.
     hooks->AddEATPatch();
     PatchLoadedModules(hooks);
+  } else {
+    base::win::DisableHandleVerifier();
   }
 }