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
_multiprocessing.Connection() doesn't check handle #47571
Comments
_multiprocessing.Connection() allows to use any positive (or nul) >>> import _multiprocessing
>>> obj = _multiprocessing.Connection(44977608)
>>> obj.poll()
Erreur de segmentation (core dumped) Fix: use fstat() to make sure that the handle is valid. Attached patch Another solution would be to reuse code from Modules/selectmodule.c. |
Ooops, there is a typo in my last patch: it's "struct stat statbuf;" |
From Victor:
I don't know if Connection() is a socket or a pipe. Both should be tested. |
I'm quite sure that neither the patch nor the new test make sense on |
Without someone offering some windows help, I won't be able to do a patch. |
Note that Windows does not crash in such cases: >>> import socket, _multiprocessing
>>> obj = _multiprocessing.Connection(44977608)
>>> obj.poll()
IOError: [Errno 10038] An operation was attempted on something that is
not a socket
>>> s = socket.socket()
>>> obj = _multiprocessing.Connection(s.fileno())
>>> obj.poll()
False
>>> s.close()
>>> obj.poll()
IOError: [Errno 10038] An operation was attempted on something that is
not a socket So some "#ifndef MS_WINDOWS" should be enough... |
I thought socket handle on BeOS is not file descripter neighter. (I'm
You mean this code? if (v < 0 || v >= FD_SETSIZE) {
PyErr_SetString(PyExc_ValueError,
"filedescriptor out of range in select()");
goto finally;
} Cygwin's thread is somewhat troublesome, so I'm not sure I can test this |
I've implemented "another solution". test_open() in $ ./dummy.exe b.py
Traceback (most recent call last):
File "b.py", line 6, in <module>
conn.poll()
IOError: [Errno 9] Bad file descriptor test_operations() will pass. |
Attached is a patch+test for this condition, which is not used if we're |
Curse you hard-tabs. Here's the new patch w/ fixed comment |
Removed raise TestSkip per code review from bpeterson |
Committed patch as r68768 to python-trunk |
@jnoller: Hey, you removed my patch! My patch used fstat() in |
The save was needed for the Py_BLOCK_THREADS call. |
Ugh, I didn't mean to chuck your original patch, but it also wasn't Additionally, if you close the handle from underneath it, it behaves >>> obj.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor
>>> |
Why don't you check the file descriptor directly in connection_new()? |
That's an enhancement - not a bad idea, I just noticed that this issue is |
Oh, I agree - I think we should update 3311 with the enhancement to move |
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: