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_interrupted_write_text() of test_io failed of Python 3.3 on FreeBSD 7.2 #56068
Comments
test_interrupted_write_text() of test_io failed of Python 3.3 on FreeBSD 7.2: [250/354] test_io
Exception in thread Thread-1316:
Traceback (most recent call last):
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/threading.py", line 735, in _bootstrap_inner
self.run()
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/threading.py", line 688, in run
self._target(*self._args, **self._kwargs)
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/test_io.py", line 2630, in _read
s = os.read(r, 1)
OSError: [Errno 4] Interrupted system call Timeout (1:00:00)! Stop in /usr/home/db3l/buildarea/3.x.bolen-freebsd7/build. |
I already read somewhere that on FreeBSD, any thread can receive a signal, not only the main thread. I suppose that it should be the same on Linux, but Linux tries maybe to send a signal to the main thread if the main thread and other threads are calling a system call. In this case, "_read" thread gets the SIGARLM signal and so its os.read() system call is interrupted. It means that os.read() is blocked at least one second, whereas wio.write() is supposed to send data to unblock _read() thread. |
One solution to fix this problem is to use pthread_sigmask() on the _read() thread to not handle SIGARLM. For example, the faulthandler uses the following code to not handle any thread in its timeout thread: #ifdef HAVE_PTHREAD_H
sigset_t set;
/* we don't want to receive any signal */
sigfillset(&set);
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
pthread_sigmask(SIG_SETMASK, &set, NULL);
#else
sigprocmask(SIG_SETMASK, &set, NULL);
#endif
#endif |
Agreed with your analysis. The problem is that the signal module doesn't expose pthread_sigmask. We could grab Jean-Paul's implementation from http://bazaar.launchpad.net/~exarkun/python-signalfd/trunk/view/head:/signalfd/_signalfd.c (although I'm not sure why the method is called "sigprocmask" while it calls pthread_sigmask). |
New changeset 28b9702a83d1 by Victor Stinner in branch 'default': |
The issue is race condition and was rare (I only saw it once on FreeBSD 7.2 3.x buildbot). I suppose that it is fixed, I'm unable to check (I am unable to reproduce the bug in my FreeBSD 8 VM). Reopen the issue if it is not fixed yet. |
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: