Author vstinner
Recipients ZackerySpytz, graingert, matrixise, serhiy.storchaka, vstinner
Date 2019-05-09.23:42:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557445330.16.0.294383981969.issue36829@roundup.psfhosted.org>
In-reply-to
Content
> The point for me is that CI will fail if it happens, then I can use gdb to find out the cause

I'm not comfortable with forcing users to use a low-level debugger to debug "unraisable exceptions".

I tried PR 13175 on the test suite by forcing the option to 1: always call Py_FatalError(). Many tests break:

14 tests failed:
    test_asyncio test_cmd_line test_coroutines test_cprofile
    test_exceptions test_generators test_import test_io
    test_raise test_repl test_signal test_ssl test_urllib
    test_yield_from

Examples:

test_error_through_destructor (test.test_io.CBufferedReaderTest) ... Fatal Python error: Unraisable exception

FAIL: test_warn_on_full_buffer (test.test_signal.WakeupSocketSignalTests)
FAIL: test_send_error (test.test_signal.WakeupSocketSignalTests)
FAIL: test_wakeup_write_error (test.test_signal.WakeupSignalTests)

test_unraisable (test.test_exceptions.ExceptionTests) ... Fatal Python error: Unraisable exception

test_generators:

Trying:
    del g
Expecting nothing
Fatal Python error: Unraisable exception

etc.

Unraisable exceptions are bad, but it's really hard to fix all of them. They are too many cases where Python is unable to pass exceptions to the parent.

If you want to make the situation better, maybe we should investigate where Python cannot raise exceptions and try to make it possible.

IMHO my PR 13187 adding sys.unraisablehook() is more usable/reasonable option.

--

Thomas Grainger: which code are you running on your CI? Did you try PR 13175 on your CI? Try it with this additional change, to always crash on PyErr_WriteUnraisable(). Does your CI still pass?

diff --git a/Include/cpython/coreconfig.h b/Include/cpython/coreconfig.h
index 375c0b641d..a775584553 100644
--- a/Include/cpython/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -426,7 +426,8 @@ typedef struct {
         .buffered_stdio = -1, \
         ._install_importlib = 1, \
         .check_hash_pycs_mode = NULL, \
-        ._frozen = -1}
+        ._frozen = -1, \
+        .abort_unraisable = 1}
 /* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */
 
 #ifdef __cplusplus
History
Date User Action Args
2019-05-09 23:42:10vstinnersetrecipients: + vstinner, serhiy.storchaka, graingert, matrixise, ZackerySpytz
2019-05-09 23:42:10vstinnersetmessageid: <1557445330.16.0.294383981969.issue36829@roundup.psfhosted.org>
2019-05-09 23:42:10vstinnerlinkissue36829 messages
2019-05-09 23:42:09vstinnercreate