diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-04-21 21:17:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-21 21:17:33 (GMT) |
commit | 3a8f8ea2aca46f9ef1e715f2c924357b6719525f (patch) | |
tree | 51be29554595113064dc78cf9f1d7702573bd23f /Modules | |
parent | 1ccbe6007e5569ab25170f8ecddd5fbbc2ef36b0 (diff) | |
download | cpython-3a8f8ea2aca46f9ef1e715f2c924357b6719525f.zip cpython-3a8f8ea2aca46f9ef1e715f2c924357b6719525f.tar.gz cpython-3a8f8ea2aca46f9ef1e715f2c924357b6719525f.tar.bz2 |
bpo-30125: Fix faulthandler.disable() on Windows (#1243)
On Windows, faulthandler.disable() now removes the exception handler
installed by faulthandler.enable().
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/faulthandler.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 2f8b624..61fc490 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -55,6 +55,9 @@ static struct { int fd; int all_threads; PyInterpreterState *interp; +#ifdef MS_WINDOWS + void *exc_handler; +#endif } fatal_error = {0, NULL, -1, 0}; #ifdef FAULTHANDLER_LATER @@ -462,7 +465,8 @@ faulthandler_enable(void) } #ifdef MS_WINDOWS - AddVectoredExceptionHandler(1, faulthandler_exc_handler); + assert(fatal_error.exc_handler == NULL); + fatal_error.exc_handler = AddVectoredExceptionHandler(1, faulthandler_exc_handler); #endif return 0; } @@ -514,7 +518,12 @@ faulthandler_disable(void) faulthandler_disable_fatal_handler(handler); } } - +#ifdef MS_WINDOWS + if (fatal_error.exc_handler != NULL) { + RemoveVectoredExceptionHandler(fatal_error.exc_handler); + fatal_error.exc_handler = NULL; + } +#endif Py_CLEAR(fatal_error.file); } |