Skip to content

Call __fastfail instead of abort() in more places #5529

@AlexGuteniev

Description

@AlexGuteniev

Where don't call abort()

Since __fastfail is considered a superior way to fail, and nobody asked for specific behavior in most of the places where we call abort, let's replace abort() calls in:

1. Places that are not implementable in !_HAS_EXCEPTIONS mode:

STL/stl/inc/xlocale

Lines 446 to 450 in cbd091e

#if _HAS_EXCEPTIONS
_Throw_bad_cast(); // lazy disallowed
#else
_CSTD abort(); // lazy disallowed
#endif

2. Places that seems like direct result of doing something wrong:

STL/stl/inc/functional

Lines 1354 to 1357 in cbd091e

[[noreturn]] _Rx __stdcall _Function_not_callable(const _Move_only_function_data&, _Types&&...) noexcept {
_CSTD abort(); // Unlike std::function, move_only_function doesn't throw bad_function_call
// (N4950 [func.wrap.move.inv]/2)
}

STL/stl/inc/utility

Lines 959 to 964 in cbd091e

_EXPORT_STD [[noreturn]] __forceinline void unreachable() noexcept /* strengthened */ {
_STL_UNREACHABLE;
#ifdef _DEBUG
_CSTD abort(); // likely to be called in debug mode, but can't be relied upon - already entered the UB territory
#endif // defined(_DEBUG)
}

3. Places that handle broken invariant:

STL/stl/inc/atomic

Lines 2992 to 2994 in cbd091e

default: // Unrecognized bit pattern
_CSTD abort();
}

4. Places that handle robust WinAPI functions failures

STL/stl/inc/xcall_once.h

Lines 97 to 99 in cbd091e

if (!_RENAME_WINDOWS_API(__std_init_once_begin_initialize)(&_Once._Opaque, 0, &_Pending, nullptr)) {
_CSTD abort();
}

5. Places that are inherently dead code paths and exist due to having to implement a virtual function:

STL/stl/inc/functional

Lines 891 to 893 in cbd091e

[[noreturn]] const type_info& _Target_type() const noexcept override {
_CSTD abort(); // shouldn't be called, see GH-3888
}


What call instead

In headers we have the following alternatives:

  • _STL_REPORT_ERROR
  • _MSVC_STL_DOOM_FUNCTION

In separately compiled code we probably should directly call __fastfail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions