Skip to content
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

Race condition in test_socket #80304

Closed
nanjekyejoannah opened this issue Feb 26, 2019 · 4 comments
Closed

Race condition in test_socket #80304

nanjekyejoannah opened this issue Feb 26, 2019 · 4 comments
Labels
3.8 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@nanjekyejoannah
Copy link
Member

BPO 36123
Nosy @vstinner, @miss-islington, @nanjekyejoannah
PRs
  • bpo-36123:race condition in test_socket #12053
  • [3.7] bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053) #12056
  • 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 2019-02-26.17:50:28.467>
    created_at = <Date 2019-02-26.12:43:13.548>
    labels = ['3.8', 'type-bug', 'tests']
    title = 'Race condition in test_socket'
    updated_at = <Date 2019-02-26.17:50:28.466>
    user = 'https://github.com/nanjekyejoannah'

    bugs.python.org fields:

    activity = <Date 2019-02-26.17:50:28.466>
    actor = 'nanjekyejoannah'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-02-26.17:50:28.467>
    closer = 'nanjekyejoannah'
    components = ['Tests']
    creation = <Date 2019-02-26.12:43:13.548>
    creator = 'nanjekyejoannah'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36123
    keywords = ['patch']
    message_count = 4.0
    messages = ['336658', '336690', '336694', '336704']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'miss-islington', 'nanjekyejoannah']
    pr_nums = ['12053', '12056']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue36123'
    versions = ['Python 3.8']

    @nanjekyejoannah
    Copy link
    Member Author

    Looking at the buildbot failures, there is a race condition in a test_socket test:

        def _testWithTimeoutTriggeredSend(self):
            address = self.serv.getsockname()
            with open(support.TESTFN, 'rb') as file:
                with socket.create_connection(address, timeout=0.01) as sock:
                    meth = self.meth_from_sock(sock)
                    self.assertRaises(socket.timeout, meth, file)
    
        def testWithTimeoutTriggeredSend(self):
            conn = self.accept_conn()
            conn.recv(88192)

    on slow buildbot, create_connection() fails with a timeout exception sometimes because the server fails to start listing in less than 10 ms.

    https://buildbot.python.org/all/#/builders/167/builds/597

    ======================================================================
    ERROR: testWithTimeoutTriggeredSend (test.test_socket.SendfileUsingSendTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py",
    line 5796, in testWithTimeoutTriggeredSend
        conn = self.accept_conn()
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py",
    line 5607, in accept_conn
        conn, addr = self.serv.accept()
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py",
    line 212, in accept
        fd, addr = self._accept()
    socket.timeout: timed out

    ======================================================================
    ERROR: testWithTimeoutTriggeredSend (test.test_socket.SendfileUsingSendTest)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py",
    line 335, in _tearDown
        raise exc
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py",
    line 353, in clientRun
        test_func()
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py",
    line 5791, in _testWithTimeoutTriggeredSend
        with socket.create_connection(address, timeout=0.01) as sock:
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py",
    line 727, in create_connection
        raise err
      File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py",
    line 716, in create_connection
        sock.connect(sa)
    socket.timeout: timed out

    Note: Reported my Victor. I created the bug to track.

    @nanjekyejoannah nanjekyejoannah added 3.8 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Feb 26, 2019
    @vstinner
    Copy link
    Member

    New changeset 53b9e1a by Victor Stinner (Joannah Nanjekye) in branch 'master':
    bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053)
    53b9e1a

    @miss-islington
    Copy link
    Contributor

    New changeset 2632474 by Miss Islington (bot) in branch '3.7':
    bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053)
    2632474

    @nanjekyejoannah
    Copy link
    Member Author

    I am closing this as it has been fixed by this PR <https://github.com/python/cpython/pull/12053\>

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants