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
Top-level exception handler writes to stdout unsafely #44242
Comments
When an exception reaches the top frame and is displayed by the exception handler, they are handled by formatting them to stderr. This involves a series of calls to PyFile_WriteString, either directly from PyErr_Display or indirectly through PyTraceBack_Print. Few, if any, of these PyFile_WriteString calls have their result checked for error. Worse, PyFile_WriteString itself does not check the return value of fputs(). So, for example, with a signal handler installed, a signal received while a traceback is being printed can result in the traceback _not_ being printed. |
I don't suppose you could wrangle up a proposed patch to fix this? |
Not likely, given the number of things on my plate already. |
Ok, thanks JP. Georg recently touched one of these functions and seemed to do the right |
I'll look into it. |
Surely it's not a good idea to attempt to generate an exception within The checks prior to fputs() handle any errors by calling err_closed() I enclose a patch to this end, please let me know whether I'm way off |
The attached patch doesn't fix the issue I described:
|
Ok, thankyou for your feedback, I will take another look at it. |
I don't see anything "easy" in this issue. Error handling in exception or signal handlers is quite tricky. I don't see this as a high priority either, but will leave this for others to decide. |
This is certainly a low-priority issue, as it will almost never happen in practice. |
I think this can be closed as out of date because PyFile_WriteString/Object no longer use puts and they do check for errors. The error checking of PyFile_WriteString/Object in the traceback display code was the subject of bpo-45635. |
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: