-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
spawnl crash on windows7 #72918
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
in window7 (using python 3.4.3,3.5.2) following script crashes import os
os.spawnl( os.P_NOWAIT, 'C:/Tcl/bin/tclsh.exe' )" Note: similar issue is already exist https://bugs.python.org/issue8036 |
small correction (removed " ) import os
os.spawnl( os.P_NOWAIT, 'C:/Tcl/bin/tclsh.exe' ) |
Just to make sure: a crash means that the Python process is killed and you get a popup or something like that? Can you please try to run the script on Python 3.6 using: python.exe -X faulthandler script.py It should display the Windows error code at least. |
spawnl is implemented by calling _spawnv 1, which is documented to invoke the invalid parameter handler if argv points to a NULL pointer. It wants the program name, or whatever, as long as argv[0] isn't NULL or an empty string, e.g. The invalid parameter handler should be disabled (_Py_BEGIN_SUPPRESS_IPH) when calling _spawnv[e], which in this case would lead to an EINVAL OSError instead of crashing the process. For example: import os, sys
from ctypes import *
ucrt = CDLL('ucrtbase')
@CFUNCTYPE(None, c_wchar_p, c_wchar_p, c_wchar_p, c_int, c_void_p)
def iph(*args):
pass
ucrt._set_thread_local_invalid_parameter_handler(iph) >>> os.spawnl(os.P_NOWAIT, sys.executable)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python35\lib\os.py", line 977, in spawnl
return spawnv(mode, file, args)
OSError: [Errno 22] Invalid argument Also, in this case a descriptive ValueError would be friendlier, given an empty argv or argv[0] that's an empty string -- at least on Windows. |
I like the idea of using _Py_BEGIN_SUPPRESS_IPH, but also the idea of |
Looks like a few functions in os module need this. os_execve_impl also doesn't release the GIL at any point, but I don't see why it shouldn't. I'll try and get to this over the weekend if nobody else comes up with a patch first. |
New changeset 02f416441def by Steve Dower in branch '3.5': |
A ValueError should also be raised when argv[0] is an empty string. |
New changeset 1a9e4b465497 by Steve Dower in branch '3.6': New changeset 75824899f0dd by Steve Dower in branch 'default': |
New changeset e076ace7b0ff by Steve Dower in branch '3.5': New changeset af78b33704af by Steve Dower in branch '3.6': New changeset fc6f757e53de by Steve Dower in branch 'default': |
Added that too. Python 3.5 is missing the tests for these functions completely, so I only added those to 3.6 and later. Also the original issue was already resolved in 3.6, but I tidied up a few other functions that were missing proper handling. |
New changeset 2e1fb851dfb4 by Steve Dower in branch '3.6': New changeset ac6de11fbd50 by Steve Dower in branch 'default': |
Buildbots seem to be happy now so I'm closing the issue. Feel free to reopen if anyone spots anything in commit review. |
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: