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
test_subprocess.test_communicate_timeout_large_ouput failure on select(): negative timeout? #55966
Comments
test test_subprocess failed -- Traceback (most recent call last):
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_subprocess.py", line 452, in test_communicate_timeout_large_ouput
self.assertRaises(subprocess.TimeoutExpired, p.communicate, timeout=0.4)
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py", line 574, in assertRaises
callableObj(*args, **kwargs)
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/subprocess.py", line 846, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/subprocess.py", line 1539, in _communicate
orig_timeout)
File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/subprocess.py", line 1670, in _communicate_with_select
self._remaining_time(endtime))
select.error: (22, 'Invalid argument')
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 32] Broken pipe |
According to POSIX, EINVAL in select() means either "an invalid timeout interval was specified" or "the nfds argument is less than 0 or greater than FD_SETSIZE". (http://www.opengroup.org/onlinepubs/007904875/functions/pselect.html) Additionally, Python's select.select() should raise ValueError if a file descriptor is outside of [0; FD_SETSIZE[, so the invalid timeout interval seems possible. |
_remaining_time doesn't check that endtime > current time and can return a negative number, which would trigger an EINVAL when passed to select (select_select doesn't seem to check for negative double). There's also a short race window if the endtime deadline expires between the call to _check_timeout and remaining_time. |
New changeset 3664fc29e867 by Victor Stinner in branch 'default': |
It seems to have fixed the failure, no ? |
Adding that check with an exception to selectmodule.c is a good idea. |
You may also patch poll_poll(). |
Poll accepts negative timeout values, since it's the only way to |
Le vendredi 08 avril 2011 à 05:34 +0000, Charles-Francois Natali a
Oh, I didn't know. In this case, is my commit 3664fc29e867 correct? I If I am correct, it is a real bug. Should it be fixed in Python 2.7, 3.1 |
Yes, it looks correct. 1537 stdout, stderr = or here: 1113 if self.stdout is not None: Also, it might be simpler and cleaner to factorize the raising of the 1514 remaining = self._remaining_time(endtime) merging what's done in _check_timeout |
New changeset 3982be773b54 by Antoine Pitrou in branch 'default': |
I think the best behavior would be to go ahead and check one last time before raising the exception, so _remaining_time should turn a negative value into 0 (assuming that a timeout value of zero does the right thing for our use case). If people don't feel that is best, refactoring _remaining_time to incorporate the check in _check_timeout would also be good. |
Is there anything left to do here? |
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: