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.signal(bogus_signal, handler) segfaults on Windows #53570
Comments
Using Python 2.7 (r27:82525, Jul 4 2010, 09:01:59; 32-bit Intel) on 64-bit Windows Server 2008 R2, python.exe (interactive sessions and files) crashes when it encounters the following snippet:
>>> import signal
>>> signal.signal(7, lambda a, b: None) Note that Python doesn't crash if I substitute '7' with a valid Windows signal (e.g., '2'). Also, it seems that at least some invalid signal inputs (e.g., '0') generate the appropriate Python exception. |
This appears to run afoul of Microsoft's "security-enhanced CRT", which aborts a program that calls certain API functions (including signal) with invalid parameters. PyOS_getsig() has conditionally-compiled code added to deal with this (and handle invalid signal values before passing them to the CRT); PyOS_setsig() should get the same treatment. |
bpo-9324.diff checks the signal value after argument parsing and before sending it onward towards the system call. It only lets you use the following signals, per http://msdn.microsoft.com/en-us/library/xdkz3x12.aspx |
Oops, note to myself that there's a long line in signalmodule.c. |
Fixed in r83763 (py3k), r83764 (release31-maint), and r83765 (release27-maint). Thanks for reporting this. |
Attached is a patch using Ronald's suggestion to rework this as a switch statement. Also included is a minor reworking that Paul noticed in Lib/test/test_signal.py. Added the people who responded to the python-dev checkin comments to the nosy list. Feel free to remove yourself. |
Checked in the suggested fixes in r84556 (py3k), r84557 (release27-maint), and r84558 (release27-maint). |
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: