Eryk Sun <eryk...@gmail.com> added the comment:

> And depending on the OS, abort() calls (via Py_FatalError) sometimes 
> appear to be segfaults, so it could be any number of issues. 
> (Aside - I'd love to replace the abort() calls with specific exit
> codes for configuration errors - they really mess up the crash data 
> we see on Windows.)

In particular, with the Universal CRT, an unhandled abort() is implemented by a 
__fastfail intrinsic [1] (int 0x29 instruction in x86) with the argument 
FAST_FAIL_FATAL_APP_EXIT (7). 

Prior to Windows 8 this appears as an access violation. In Windows 8+ it's 
implemented as a second-chance STATUS_STACK_BUFFER_OVERRUN (0xC0000409) 
exception, which is overloaded from its previous use to support failure codes. 
(The old usage appears as the failure code FAST_FAIL_LEGACY_GS_VIOLATION, 
defined to be 0.) It starts as a second-chance exception in order to bypass 
normal exception handling (i.e. SEH, VEH, UnhandledExceptionFilter). The 
second-chance exception event is sent to an attached debugger and/or the 
session server (csrss.exe).

Python's normal signal handling for SIGABRT can't prevent this, since the C 
handler just sets a flag and returns. But enabling faulthandler sets a C signal 
handler that restores the previous handler and calls raise(SIGABRT). The 
default SIGABRT handler for the explicit raise() code path simply calls 
_exit(3). 

Alternatively, we could prevent the __fastfail call via _set_abort_behavior 
[2], if implemented in msvcrt. For example: msvcrt.set_abort_behavior(0, 
msvcrt.CALL_REPORTFAULT).

[1]: https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
[2]: 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-abort-behavior

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36116>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to