forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crash fast in case of an exception from ATL.
BUG=108176 TBR=fdoray@chromium.org, nicolaso@chromium.org Change-Id: I076fa8233729c8006c1963492ccf3a3bce36a78b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212046 Reviewed-by: Greg Thompson <grt@chromium.org> Commit-Queue: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#771244}
- Loading branch information
Showing
9 changed files
with
108 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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). | ||
#ifndef _ATL_NO_EXCEPTIONS | ||
#define _ATL_NO_EXCEPTIONS | ||
#endif | ||
|
||
#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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters