-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Py_FatalError(): dump the list of extension modules #87089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When Python cannot report an error and its is not possible to recover from the error, Py_FatalError() displays an error message and exit immediately Python. It's common that Python crashes are coming from third party extension modules, rather than Python itself. Recent example: bpo-42891 crash reported in Python, but it was a bug in lsm-db third party extension module. I propose to enhance Py_FatalError() to attempt to dump the list of extension modules, to ease debugging. I'm working on a PR. |
Example using PR 24207, the new part the "Extension modules:" list at the end: $ ./python -X faulthandler
Python 3.10.0a4+ (heads/master-dirty:2396614b89, Jan 13 2021, 12:09:15)
>>> import ctypes
>>> ctypes.string_at(0)
Fatal Python error: Segmentation fault Current thread 0x00007f0aabd09740 (most recent call first): Extension modules:
Here you can see that the _ctypes module is loaded. |
Another recent example: bpo-42879 "python: Objects/abstract.c:155: PyObject_GetItem: Assertion `(item != NULL) ^ (PyErr_Occurred() != NULL)' failed." was a bug in pygame. |
Example of a Pillow crash in Python 3.10: |
I created https://bugs.python.org/issue42955 to add sys.modules_names tuple: names of stdlib modules. Once it will be merged, I will updated this PR to filter the list of modules (ignore stdlib modules). |
More "real world" example using cinder which imports 220 modules (ctypes is used to simulate a crash): $ ./python -m venv env
$ env/bin/python -m pip install wheel
$ env/bin/python -m pip install cinder
$ env/bin/python -X dev -c 'import cinder, ctypes, sys; print(f"{len(sys.modules)=}"); print(); ctypes.string_at(0)'
(...)
len(sys.modules)=220 Fatal Python error: Segmentation fault Current thread 0x00007fc4a88e0740 (most recent call first): Extension modules: greenlet._greenlet, __original_module__thread, __original_module_select, __original_module_time, _cffi_backend (total: 5) cinder only uses 2 third party extension modules (on a total of 220 modules): greenlet and cffi. Note: __original_xxx modules are aliases of stdlib modules created by eventlet monkey patching. So if cinder does crash, I suggest to look at Python, but *also* look at these 2 extensions ;-) |
See also bpo-42955 "Add sys.module_names: list of stdlib module names (Python and extension modules)". |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: