Skip to content

test_interrupted_write_text() of test_io failed of Python 3.3 on FreeBSD 7.2 #56068

Closed

Description

@vstinner
BPO 11859
Nosy @pitrou, @vstinner

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:

assignee = None
closed_at = <Date 2011-07-04.12:32:50.562>
created_at = <Date 2011-04-16.22:57:09.361>
labels = ['tests']
title = 'test_interrupted_write_text() of test_io failed of Python 3.3 on FreeBSD 7.2'
updated_at = <Date 2011-07-04.12:32:50.562>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2011-07-04.12:32:50.562>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2011-07-04.12:32:50.562>
closer = 'vstinner'
components = ['Tests']
creation = <Date 2011-04-16.22:57:09.361>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 11859
keywords = []
message_count = 6.0
messages = ['133908', '133909', '133910', '133923', '134863', '134940']
nosy_count = 3.0
nosy_names = ['exarkun', 'pitrou', 'vstinner']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue11859'
versions = ['Python 3.3']

Activity

  1. vstinner commented on Apr 16, 2011

    @vstinner
    MemberAuthor

    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)!
    Thread 0x28401040:
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/test_io.py", line 2651 in check_interrupted_write
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/test_io.py", line 2672 in test_interrupted_write_text
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/case.py", line 387 in _executeTestPart
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/case.py", line 442 in run
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/case.py", line 494 in __call__
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/suite.py", line 105 in run
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/suite.py", line 67 in __call__
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/suite.py", line 105 in run
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/unittest/suite.py", line 67 in __call__
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/support.py", line 1078 in run
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/support.py", line 1166 in _run_suite
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/support.py", line 1192 in run_unittest
    File "/usr/home/db3l/buildarea/3.x.bolen-freebsd7/build/Lib/test/test_io.py", line 2845 in test_main
    File "./Lib/test/regrtest.py", line 1041 in runtest_inner
    File "./Lib/test/regrtest.py", line 835 in runtest
    File "./Lib/test/regrtest.py", line 659 in main
    File "./Lib/test/regrtest.py", line 1619 in <module>
    *** Error code 1

    Stop in /usr/home/db3l/buildarea/3.x.bolen-freebsd7/build.
    program finished with exit code 1
    elapsedTime=8703.824572
    -----------------------------------------------
    http://www.python.org/dev/buildbot/all/builders/x86%20FreeBSD%207.2%203.x/builds/1695/steps/test/logs/stdio

  2. vstinner commented on Apr 16, 2011

    @vstinner
    MemberAuthor

    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.

  3. vstinner commented on Apr 16, 2011

    @vstinner
    MemberAuthor

    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
  4. pitrou commented on Apr 17, 2011

    @pitrou
    Member

    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).

  5. vstinner commented on Apr 30, 2011

    @vstinner
    MemberAuthor

    New changeset 28b9702a83d1 by Victor Stinner in branch 'default':
    Issue bpo-8407, issue bpo-11859: Add signal.pthread_sigmask() function to fetch
    http://hg.python.org/cpython/rev/28b9702a83d1

  6. vstinner commented on May 1, 2011

    @vstinner
    MemberAuthor

    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.

  7. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions