Chromium Code Reviews| Index: base/win/scoped_handle.cc |
| diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc |
| index c429375b9cbb4a9a373508eb574b5e68627cc605..65b5b74762397418ee7fcfefb542846b27638a66 100644 |
| --- a/base/win/scoped_handle.cc |
| +++ b/base/win/scoped_handle.cc |
| @@ -117,6 +117,8 @@ ActiveVerifier* ActiveVerifier::Get() { |
| void ActiveVerifier::InstallVerifier() { |
| #if defined(COMPONENT_BUILD) |
| AutoNativeLock lock(g_lock.Get()); |
| + if (g_active_verifier) |
| + return; |
| g_active_verifier = new ActiveVerifier(true); |
| #else |
| // If you are reading this, wondering why your process seems deadlocked, take |
| @@ -128,17 +130,34 @@ void ActiveVerifier::InstallVerifier() { |
| reinterpret_cast<GetHandleVerifierFn>(::GetProcAddress( |
| main_module, "GetHandleVerifier")); |
| + // This should only happen if running in a DLL is linked with base but the |
| + // hosting EXE is not. In this case, create an ActiveVerifier for the current |
| + // module but leave it disabled. |
| if (!get_handle_verifier) { |
| g_active_verifier = new ActiveVerifier(false); |
| return; |
| } |
| - ActiveVerifier* verifier = |
| + // Check if in the main module. |
| + if (get_handle_verifier == GetHandleVerifier) { |
| + AutoNativeLock lock(g_lock.Get()); |
| + if (g_active_verifier) |
| + return; |
| + g_active_verifier = new ActiveVerifier(true); |
| + return; |
| + } |
| + |
| + ActiveVerifier* main_module_verifier = |
| reinterpret_cast<ActiveVerifier*>(get_handle_verifier()); |
| + // Main module should always on-demand create a verifier. |
| + DCHECK(main_module_verifier); |
| + |
| // This lock only protects against races in this module, which is fine. |
| AutoNativeLock lock(g_lock.Get()); |
| - g_active_verifier = verifier ? verifier : new ActiveVerifier(true); |
| + if (g_active_verifier) |
|
scottmg
2016/03/10 20:31:26
Maybe an extra comment here describing what we dis
Will Harris
2016/03/10 21:08:45
Done.
|
| + return; |
| + g_active_verifier = main_module_verifier; |
| #endif |
| } |
| @@ -221,7 +240,7 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) { |
| } // namespace |
| void* GetHandleVerifier() { |
| - return g_active_verifier; |
| + return ActiveVerifier::Get(); |
| } |
| namespace base { |