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
Signal handlers must preserve errno #54520
Comments
Signal handlers that can change errno, must restore it. The patch does if (errno != save_errno) errno = save_errno; I don't know what needs to be done on non-Unix systems, |
This is a good idea IMO. It would be better if you minimized style changes, so that the patch is easier to review. |
Parser/intrcheck.c:intcatcher() should do the same. Covered in Issue Antoine Pitrou writes:
I'm afraid the un-rearranged code would be fairly ugly, so I cleaned
Whoops, I'd forgotten I did that too, it was on my TODO list to |
This issue is not really relevant on Windows:
|
Amaury Forgeot d'Arc writes:
Nice. Then I suggest a config macro for whether this is needed. |
I'm quite sure that all Unixes invoke signal handlers in some existing thread. So even if errno is thread-local, it needs to be saved and restored. |
Amaury Forgeot d'Arc writes:
["this" = only saving/restoring errno when needed] |
I think it is extremely unlikely that mutating errno in a signal handler is unsafe (after all, the library functions called from that handler can mutate errno too: that's the whole point of the patch IIUC). Adding some configure machinery for this seems unwarranted to me. |
By the way, I'd like to clear out a potential misunderstanding: the function you are patching doesn't call Python signal handlers in itself (those registered using signal.signal()). It only schedules them for later execution. If you want to save errno around Python signal handlers themselves, PyErr_CheckSignals must be patched as well. |
Antoine Pitrou writes:
Good point - I'm talking C signal handlers, not Python signal handlers.
Probably not. I don't know Python's errno conventions, if any, but |
Antoine Pitrou writes:
Fine by me. |
Ok, fixed in r86214 (3.x), r86215 (3.1) and r86216 (2.7). Thanks for the patch! |
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: