ReactOS 0.4.16-dev-889-g9563c07
abort.cpp
Go to the documentation of this file.
1/***
2*abort.c - abort a program by raising SIGABRT
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* defines abort() - print a message and raise SIGABRT.
8*
9*******************************************************************************/
10
11#include <corecrt_internal.h>
12#include <signal.h>
13#include <stdlib.h>
14
15#ifdef _DEBUG
16 #define _INIT_ABORT_BEHAVIOR _WRITE_ABORT_MSG
17#else
18 #define _INIT_ABORT_BEHAVIOR _CALL_REPORTFAULT
19#endif
20
21extern "C" { unsigned int __abort_behavior = _INIT_ABORT_BEHAVIOR; }
22
23/***
24*void abort() - abort the current program by raising SIGABRT
25*
26*Purpose:
27* print out an abort message and raise the SIGABRT signal. If the user
28* hasn't defined an abort handler routine, terminate the program
29* with exit status of 3 without cleaning up.
30*
31* Multi-thread version does not raise SIGABRT -- this isn't supported
32* under multi-thread.
33*
34*Entry:
35* None.
36*
37*Exit:
38* Does not return.
39*
40*Uses:
41*
42*Exceptions:
43*
44*******************************************************************************/
45
46extern "C" void __cdecl abort()
47{
48 #ifdef _DEBUG
50 {
51 __acrt_report_runtime_error(L"abort() has been called");
52 }
53 #endif
54
55
56 /* Check if the user installed a handler for SIGABRT.
57 * We need to read the user handler atomically in the case
58 * another thread is aborting while we change the signal
59 * handler.
60 */
62 if (sigabrt_action != SIG_DFL)
63 {
65 }
66
67 /* If there is no user handler for SIGABRT or if the user
68 * handler returns, then exit from the program anyway
69 */
70
72 {
73 #if defined _M_ARM || defined _M_ARM64 || defined _M_ARM64EC || defined _UCRT_ENCLAVE_BUILD
75 #else
78
80 #endif
81 }
82
83
84 /* If we don't want to call ReportFault, then we call _exit(3), which is the
85 * same as invoking the default handler for SIGABRT
86 */
87
88
89 _exit(3);
90}
91
92/***
93*unsigned int _set_abort_behavior(unsigned int, unsigned int) - set the behavior on abort
94*
95*Purpose:
96*
97*Entry:
98* unsigned int flags - the flags we want to set
99* unsigned int mask - mask the flag values
100*
101*Exit:
102* Return the old behavior flags
103*
104*Exceptions:
105* None
106*
107*******************************************************************************/
108
109extern "C" unsigned int __cdecl _set_abort_behavior(unsigned int flags, unsigned int mask)
110{
111 unsigned int oldflags = __abort_behavior;
112 __abort_behavior = oldflags & (~mask) | flags & mask;
113 return oldflags;
114}
void _exit(int exitcode)
Definition: _exit.c:25
#define _INIT_ABORT_BEHAVIOR
Definition: abort.cpp:18
unsigned int __abort_behavior
Definition: abort.cpp:21
void __cdecl abort()
Definition: abort.cpp:46
unsigned int __cdecl _set_abort_behavior(unsigned int flags, unsigned int mask)
Definition: abort.cpp:109
#define __cdecl
Definition: accygwin.h:79
void(__cdecl * __crt_signal_handler_t)(int)
__crt_signal_handler_t __cdecl __acrt_get_sigabrt_handler(void)
Definition: signal.cpp:564
void __cdecl __acrt_call_reportfault(int nDbgHookCode, DWORD dwExceptionCode, DWORD dwExceptionFlags)
void __cdecl __acrt_report_runtime_error(_In_z_ wchar_t const *message)
int __cdecl raise(int _SigNum)
Definition: signal.c:71
#define SIG_DFL
Definition: signal.h:47
#define SIGABRT
Definition: signal.h:28
BOOL WINAPI IsProcessorFeaturePresent(IN DWORD ProcessorFeature)
Definition: sysinfo.c:169
GLenum GLint GLuint mask
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161
#define _CALL_REPORTFAULT
Definition: stdlib.h:116
#define _WRITE_ABORT_MSG
Definition: stdlib.h:115
#define _CRT_DEBUGGER_ABORT
__fastfail(FAST_FAIL_INVALID_ARG)
#define STATUS_FATAL_APP_EXIT
Definition: ntstatus.h:135
#define L(x)
Definition: ntvdm.h:50
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
#define PF_FASTFAIL_AVAILABLE
Definition: ketypes.h:147
#define FAST_FAIL_FATAL_APP_EXIT