Commit add913dc authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Crash fast in case of an exception from ATL.

BUG=108176
TBR=fdoray@chromium.org

Change-Id: I9723b07932b35fd098e40965735d1e92cb0c8946
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210466
Commit-Queue: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771073}
parent 07d412c9
...@@ -1003,6 +1003,8 @@ jumbo_component("base") { ...@@ -1003,6 +1003,8 @@ jumbo_component("base") {
"trace_event/trace_event_etw_export_win.h", "trace_event/trace_event_etw_export_win.h",
"win/async_operation.h", "win/async_operation.h",
"win/atl.h", "win/atl.h",
"win/atl_throw.cc",
"win/atl_throw.h",
"win/com_init_check_hook.cc", "win/com_init_check_hook.cc",
"win/com_init_check_hook.h", "win/com_init_check_hook.h",
"win/com_init_util.cc", "win/com_init_util.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef BASE_WIN_ATL_H_ #ifndef BASE_WIN_ATL_H_
#define BASE_WIN_ATL_H_ #define BASE_WIN_ATL_H_
...@@ -9,10 +10,6 @@ ...@@ -9,10 +10,6 @@
// Undefine before windows header will make the poisonous defines // Undefine before windows header will make the poisonous defines
#include "base/win/windows_undefines.inc" #include "base/win/windows_undefines.inc"
#ifndef _ATL_NO_EXCEPTIONS
#define _ATL_NO_EXCEPTIONS
#endif
// atlwin.h relies on std::void_t, but libc++ doesn't define it unless // atlwin.h relies on std::void_t, but libc++ doesn't define it unless
// _LIBCPP_STD_VER > 14. Workaround this by manually defining it. // _LIBCPP_STD_VER > 14. Workaround this by manually defining it.
#include <type_traits> #include <type_traits>
...@@ -23,6 +20,9 @@ using void_t = void; ...@@ -23,6 +20,9 @@ using void_t = void;
} }
#endif #endif
// Declare our own exception thrower (atl_throw.h includes atldef.h).
#include "base/win/atl_throw.h"
#include <atlbase.h> #include <atlbase.h>
#include <atlcom.h> #include <atlcom.h>
#include <atlctl.h> #include <atlctl.h>
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win/atl_throw.h"
#include <winerror.h>
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "base/immediate_crash.h"
#include "base/process/memory.h"
namespace base {
namespace win {
NOINLINE void __stdcall AtlThrowImpl(HRESULT hr) {
base::debug::Alias(&hr);
if (hr == E_OUTOFMEMORY)
base::TerminateBecauseOutOfMemory(0);
IMMEDIATE_CRASH();
}
} // namespace win
} // namespace base
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_WIN_ATL_THROW_H_
#define BASE_WIN_ATL_THROW_H_
#ifdef __ATLDEF_H__
#error atl_throw.h must be included before atldef.h.
#endif
#include "base/base_export.h"
#include "base/win/windows_types.h"
// Defining _ATL_NO_EXCEPTIONS causes ATL to raise a structured exception
// instead of throwing a CAtlException. While crashpad will eventually handle
// this, the HRESULT that caused the problem is lost. So, in addition, define
// our own custom AtlThrow function (_ATL_CUSTOM_THROW).
#define _ATL_NO_EXCEPTIONS
#define _ATL_CUSTOM_THROW
#define AtlThrow ::base::win::AtlThrowImpl
namespace base {
namespace win {
// Crash the process forthwith in case of ATL errors.
[[noreturn]] BASE_EXPORT void __stdcall AtlThrowImpl(HRESULT hr);
} // namespace win
} // namespace base
#include <atldef.h>
// atldef.h mistakenly leaves out the declaration of this function when
// _ATL_CUSTOM_THROW is defined.
namespace ATL {
ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowLastWin32();
}
#endif // BASE_WIN_ATL_THROW_H_
...@@ -58,7 +58,7 @@ shared_library("browser_switcher_bho") { ...@@ -58,7 +58,7 @@ shared_library("browser_switcher_bho") {
] ]
} else { } else {
sources = [ sources = [
"//base/win/atl.h", "atl.h",
"bho.cc", "bho.cc",
"bho.h", "bho.h",
"browser_switcher_core.cc", "browser_switcher_core.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_BROWSER_SWITCHER_BHO_ATL_H_
#define CHROME_BROWSER_BROWSER_SWITCHER_BHO_ATL_H_
#ifndef _ATL_NO_EXCEPTIONS
#define _ATL_NO_EXCEPTIONS
#endif
// atlwin.h relies on std::void_t, but libc++ doesn't define it unless
// _LIBCPP_STD_VER > 14. Workaround this by manually defining it.
#include <type_traits>
#if defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER <= 14
namespace std {
template <class...>
using void_t = void;
}
#endif
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#include <atlhost.h>
#include <atlsecurity.h>
#include <atlwin.h>
#endif // CHROME_BROWSER_BROWSER_SWITCHER_BHO_ATL_H_
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_BROWSER_SWITCHER_BHO_BHO_H_ #ifndef CHROME_BROWSER_BROWSER_SWITCHER_BHO_BHO_H_
#define CHROME_BROWSER_BROWSER_SWITCHER_BHO_BHO_H_ #define CHROME_BROWSER_BROWSER_SWITCHER_BHO_BHO_H_
#include "base/win/atl.h" #include "chrome/browser/browser_switcher/bho/atl.h"
#include <exdispid.h> // NOLINT(build/include_order) #include <exdispid.h> // NOLINT(build/include_order)
#include <shlguid.h> // NOLINT(build/include_order) #include <shlguid.h> // NOLINT(build/include_order)
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
#include <ShlObj.h> #include <ShlObj.h>
#include "base/win/atl.h" #include "chrome/browser/browser_switcher/bho/atl.h"
#include "chrome/browser/browser_switcher/bho/ie_bho_idl.h" #include "chrome/browser/browser_switcher/bho/ie_bho_idl.h"
#include "chrome/browser/browser_switcher/bho/logging.h" #include "chrome/browser/browser_switcher/bho/logging.h"
#include "chrome/browser/browser_switcher/bho/resource.h" #include "chrome/browser/browser_switcher/bho/resource.h"
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "chrome/installer/setup/install_worker.h" #include "chrome/installer/setup/install_worker.h"
#include <atlsecurity.h> #include "base/win/atl.h"
#include <oaidl.h> #include <oaidl.h>
#include <sddl.h> #include <sddl.h>
#include <shlobj.h> #include <shlobj.h>
......
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