Skip to content

test_ssl logs a traceback #75501

Closed
Closed

Description

@vstinner
BPO 31320
Nosy @pitrou, @vstinner, @tiran, @alex, @vadmium, @dstufft, @Mariatta
PRs
  • bpo-31320: No traceback to sys.stderr in test_ssl #3360
  • [3.6] bpo-31320: No traceback to sys.stderr in test_ssl (GH-3360) #3369
  • 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 2017-09-13.00:54:27.421>
    created_at = <Date 2017-09-01.14:39:37.775>
    labels = ['3.7', 'tests']
    title = 'test_ssl logs a traceback'
    updated_at = <Date 2017-09-13.00:54:27.420>
    user = 'https://github.com/vstinner'
    

    bugs.python.org fields:

    activity = <Date 2017-09-13.00:54:27.420>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-09-13.00:54:27.421>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2017-09-01.14:39:37.775>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31320
    keywords = []
    message_count = 9.0
    messages = ['301107', '301108', '301110', '301119', '301209', '301375', '301403', '301425', '302020']
    nosy_count = 8.0
    nosy_names = ['janssen', 'pitrou', 'vstinner', 'christian.heimes', 'alex', 'martin.panter', 'dstufft', 'Mariatta']
    pr_nums = ['3360', '3369']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue31320'
    versions = ['Python 3.6', 'Python 3.7']
    

    Activity

    1. vstinner commented on Sep 1, 2017

      @vstinner
      MemberAuthor

      It would be nice to not log such traceback:

      haypo@selma$ ./python -m test test_ssl -m test.test_ssl.ThreadedTests.test_echo
      Run tests sequentially
      0:00:00 load avg: 0.69 [1/1] test_ssl
      Exception in thread Thread-16:
      Traceback (most recent call last):
        File "/home/haypo/prog/python/master/Lib/threading.py", line 917, in _bootstrap_inner
          self.run()
        File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1936, in run
          if not self.wrap_conn():
        File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1881, in wrap_conn
          self.sock, server_side=True)
        File "/home/haypo/prog/python/master/Lib/ssl.py", line 401, in wrap_socket
          _context=self, _session=session)
        File "/home/haypo/prog/python/master/Lib/ssl.py", line 808, in __init__
          self.do_handshake()
        File "/home/haypo/prog/python/master/Lib/ssl.py", line 1061, in do_handshake
          self._sslobj.do_handshake()
        File "/home/haypo/prog/python/master/Lib/ssl.py", line 683, in do_handshake
          self._sslobj.do_handshake()
      OSError: [Errno 0] Error
      

      1 test OK.

      Total duration: 205 ms
      Tests result: SUCCESS

    2. added
      3.7 (EOL)
      tests
      on Sep 1, 2017
    3. vstinner commented on Sep 1, 2017

      @vstinner
      MemberAuthor

      Python 2.7 doesn't seem to be affected.

    4. pitrou commented on Sep 1, 2017

      @pitrou
      Member

      I don't get such traceback here (Ubuntu 16.04, OpenSSL 1.0.2g).

    5. vstinner commented on Sep 1, 2017

      @vstinner
      MemberAuthor

      I'm running Fedora 26:

      haypo@selma$ ./python -m test.pythoninfo|grep -E 'ssl|platform'
      platform.architecture: 32bit ELF
      platform.platform: Linux-4.12.5-300.fc26.x86_64-x86_64-with-fedora-26-Twenty_Six
      platform.python_implementation: CPython
      ssl.HAS_SNI: True
      ssl.OPENSSL_VERSION: OpenSSL 1.1.0f-fips 25 May 2017
      ssl.OPENSSL_VERSION_INFO: (1, 1, 0, 6, 15)
      ssl.OP_ALL: -0x7fffffac
      ssl.OP_NO_TLSv1_1: 0x10000000
      sys.platform: linux

    6. vadmium commented on Sep 4, 2017

      @vadmium
      Member

      Not sure if you just want to hide the presence of the exception and traceback. But regarding the exception itself (OSError with errno 0), this is not ideal. From memory, you tend to get this when the connection is shut down insecurely at the TCP level. A better exception would be SSLEOFError. Similar report in bpo-31122 (same wrap_socket → do_handshake chain). Probably also relevant: bpo-10808.

    7. tiran commented on Sep 5, 2017

      @tiran
      Member

      The error occurs in the test case that uses a PROTOCOL_TLS_SERVER context for both client and server context. In that case, OpenSSL wrap_socket() fails internally and OpenSSL raises an OSError with errno 0.

      Simple fix: catch OSError in the client thread and fail the test appropriately.

    8. tiran commented on Sep 5, 2017

      @tiran
      Member

      New changeset 305e56c by Christian Heimes in branch 'master':
      bpo-31320: No traceback to sys.stderr in test_ssl (bpo-3360)
      305e56c

    9. Mariatta commented on Sep 6, 2017

      @Mariatta
      Member

      New changeset c506403 by Mariatta (Miss Islington (bot)) in branch '3.6':
      [3.6] bpo-31320: No traceback to sys.stderr in test_ssl (GH-3360) (GH-3369)
      c506403

    10. vstinner commented on Sep 13, 2017

      @vstinner
      MemberAuthor

      Thanks for the fix Christian.

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

      3.7 (EOL)tests

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions