Skip to content

Commit

Permalink
Call abort() in terribly broken states (#3906)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
Co-authored-by: Casey Carter <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2023
1 parent e2b6a81 commit 2c2cac5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -1126,11 +1126,11 @@ private:
#ifdef _M_CEE_PURE
// permanent workaround to avoid mentioning _purecall in msvcurt.lib, ptrustu.lib, or other support libs
virtual void _Destroy() noexcept {
_STD terminate();
_CSTD abort();
}

virtual void _Delete_this() noexcept {
_STD terminate();
_CSTD abort();
}
#else // ^^^ _M_CEE_PURE / !_M_CEE_PURE vvv
virtual void _Destroy() noexcept = 0; // destroy managed resource
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/yvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ _STL_DISABLE_CLANG_WARNINGS

#ifndef _STL_CRT_SECURE_INVALID_PARAMETER
#ifdef _STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER
#define _STL_CRT_SECURE_INVALID_PARAMETER(expr) ::abort()
#define _STL_CRT_SECURE_INVALID_PARAMETER(expr) _CSTD abort()
#elif defined(_DEBUG) // avoid emitting unused long strings for function names; see GH-1956
#define _STL_CRT_SECURE_INVALID_PARAMETER(expr) ::_invalid_parameter(_CRT_WIDE(#expr), L"", __FILEW__, __LINE__, 0)
#else // _DEBUG
Expand Down
8 changes: 4 additions & 4 deletions stl/src/excptptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace {
alignas(_Ty) static unsigned char _Storage[sizeof(_Ty)];
if (!_Execute_once(_Flag, _Immortalize_impl<_Ty>, &_Storage)) {
// _Execute_once should never fail if the callback never fails
_STD terminate();
_CSTD abort();
}

return reinterpret_cast<_Ty&>(_Storage);
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace {
const auto _PThrow = _CppEhRecord.params.pThrowInfo;
if (!_PThrow) {
// No ThrowInfo exists. If this was a C++ exception, something must have corrupted it.
abort();
_CSTD abort();
}

if (!_CppEhRecord.params.pExceptionObject) {
Expand Down Expand Up @@ -489,7 +489,7 @@ _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCurrentException(void*
const auto _PThrow = _CppRecord.params.pThrowInfo;
if (!_CppRecord.params.pExceptionObject || !_PThrow || !_PThrow->pCatchableTypeArray) {
// Missing or corrupt ThrowInfo. If this was a C++ exception, something must have corrupted it.
abort();
_CSTD abort();
}

#if _EH_RELATIVE_TYPEINFO
Expand All @@ -502,7 +502,7 @@ _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCurrentException(void*

if (_CatchableTypeArray->nCatchableTypes <= 0) {
// Ditto corrupted.
abort();
_CSTD abort();
}

// we finally got the type info we want
Expand Down
4 changes: 2 additions & 2 deletions stl/src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ _EXTERN_C

void __stdcall __std_fs_close_handle(const __std_fs_file_handle _Handle) noexcept { // calls CloseHandle
if (_Handle != __std_fs_file_handle::_Invalid && !CloseHandle(reinterpret_cast<HANDLE>(_Handle))) {
terminate();
_CSTD abort();
}
}

Expand Down Expand Up @@ -252,7 +252,7 @@ static_assert(alignof(WIN32_FIND_DATAW) == alignof(__std_fs_find_data));

void __stdcall __std_fs_directory_iterator_close(_In_ const __std_fs_dir_handle _Handle) noexcept {
if (_Handle != __std_fs_dir_handle::_Invalid && !FindClose(reinterpret_cast<HANDLE>(_Handle))) {
terminate();
_CSTD abort();
}
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/iosptrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ __PURE_APPDOMAIN_GLOBAL static void(__cdecl* atfuns_cdecl[_Nats])() = {};
__PURE_APPDOMAIN_GLOBAL static size_t atcount_cdecl = _Nats;
_MRTIMP2 void __cdecl _Atexit(void(__cdecl* pf)()) { // add to wrapup list
if (atcount_cdecl == 0) {
abort(); // stack full, give up
_CSTD abort(); // stack full, give up
} else {
atfuns_cdecl[--atcount_cdecl] = reinterpret_cast<void(__cdecl*)()>(EncodePointer(reinterpret_cast<void*>(pf)));
}
Expand Down
2 changes: 1 addition & 1 deletion stl/src/primitives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Concurrency {

void wait(_Stl_critical_section* lock) {
if (!wait_for(lock, INFINITE)) {
std::terminate();
_CSTD abort();
}
}

Expand Down

0 comments on commit 2c2cac5

Please sign in to comment.