This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, lukasz.langa, pablogsal, paul.moore, pitrou, steve.dower, tim.golden, vstinner, zach.ware
Date 2019-02-27.22:19:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551305998.77.0.661456118793.issue36116@roundup.psfhosted.org>
In-reply-to
Content
> 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
History
Date User Action Args
2019-02-27 22:19:58eryksunsetrecipients: + eryksun, paul.moore, pitrou, vstinner, tim.golden, lukasz.langa, zach.ware, steve.dower, pablogsal
2019-02-27 22:19:58eryksunsetmessageid: <1551305998.77.0.661456118793.issue36116@roundup.psfhosted.org>
2019-02-27 22:19:58eryksunlinkissue36116 messages
2019-02-27 22:19:58eryksuncreate