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.

classification
Title: PEP 475: Enhance faulthandler to handle better reentrant calls
Type: Stage:
Components: Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: neologix, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2015-04-01 09:43 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py_write_noraise.patch vstinner, 2015-04-01 09:43 review
traceback_eintr.patch vstinner, 2015-04-01 09:44 review
faulthandler_eintr.patch vstinner, 2015-04-01 09:44 review
Messages (2)
msg239776 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-04-01 09:43
While working on the PEP 475, I noticed that the faulthandler module doesn't handle well reentrant calls to its signal handlers. If a signal is received while faulthandler is displaying the traceback, faulthandler restarts to display a new traceback (and then finish to display the previous traceback).

Moreover, faulthandler uses the C function write() to display the traceback and it ignores write() errors. It should retry write() if write() is interrupted by a signal (fails with EINTR).

Attached py_write_noraise.patch:

- Add a new _Py_write_noraise() function
- Document functions releasing the GIL

Attached traceback_eintr.patch:

- Modify functions displaying traceback to use _Py_write_noraise() instead of write()

Attached faulthandler_eintr.patch:

- Add a reentrant flag to the two signal handlers of faulthandler
- Modify faulthandler.dump_traceback() to call PyErr_CheckSignals(), to call the Python signal handler if a signal was received while faulthandler was displaying the traceback of all Python threads
msg239829 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-04-01 16:51
New changeset 60e001ec141d by Victor Stinner in branch 'default':
Issue #23836: Add _Py_write_noraise() function
https://hg.python.org/cpython/rev/60e001ec141d

New changeset d9b9e2a68e7c by Victor Stinner in branch 'default':
Issue #23836: Document functions releasing the GIL in fileutils.c
https://hg.python.org/cpython/rev/d9b9e2a68e7c

New changeset 12e065efc821 by Victor Stinner in branch 'default':
Issue #23836: Use _Py_write_noraise() to retry on EINTR in trip_signal() of
https://hg.python.org/cpython/rev/12e065efc821

New changeset e3c97621d8b4 by Victor Stinner in branch 'default':
Issue #23836: Use _Py_write_noraise() to retry on EINTR in child_exec() of
https://hg.python.org/cpython/rev/e3c97621d8b4

New changeset 29ab05c5e9dc by Victor Stinner in branch 'default':
Issue #23836: Use _Py_write_noraise() to retry on EINTR in _Py_DumpTraceback()
https://hg.python.org/cpython/rev/29ab05c5e9dc

New changeset f07b855afbb2 by Victor Stinner in branch 'default':
Issue #23836: Fix the faulthandler module to handle reentrant calls
https://hg.python.org/cpython/rev/f07b855afbb2
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 68024
2015-04-01 16:52:11vstinnersetstatus: open -> closed
resolution: fixed
2015-04-01 16:51:54python-devsetnosy: + python-dev
messages: + msg239829
2015-04-01 09:45:04vstinnerlinkissue23648 dependencies
2015-04-01 09:44:47vstinnersetnosy: + neologix
2015-04-01 09:44:11vstinnersetfiles: + faulthandler_eintr.patch
2015-04-01 09:44:06vstinnersetfiles: + traceback_eintr.patch
2015-04-01 09:43:59vstinnercreate