Skip to content

asyncore does not handle EINTR in recv, send, connect, accept, #55475

Closed

Description

@socketpair
BPO 11266
Nosy @vstinner, @giampaolo, @socketpair
Superseder
  • bpo-18885: handle EINTR in the stdlib
  • 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 2014-07-24.16:36:25.826>
    created_at = <Date 2011-02-21.05:31:30.435>
    labels = ['type-bug', 'library']
    title = 'asyncore does not handle EINTR in recv, send, connect, accept,'
    updated_at = <Date 2014-07-24.16:36:25.825>
    user = 'https://github.com/socketpair'

    bugs.python.org fields:

    activity = <Date 2014-07-24.16:36:25.825>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-07-24.16:36:25.826>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2011-02-21.05:31:30.435>
    creator = 'socketpair'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11266
    keywords = []
    message_count = 6.0
    messages = ['128940', '130015', '130103', '130104', '130106', '221748']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'giampaolo.rodola', 'segfaulthunter', 'nvetoshkin', 'socketpair']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '18885'
    type = 'behavior'
    url = 'https://bugs.python.org/issue11266'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

    Activity

    1. socketpair commented on Feb 21, 2011

      socketpairmannequin
      MannequinAuthor

      in spite of usage of non-blocking IO, syscalls may return EINTR if signal arrive during some syscalls.

      It is desirable to re-call syscall after receiving EINTR. Trivial loops should be implemented around (recv, send, connect, accept)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Feb 21, 2011
    3. giampaolo commented on Mar 3, 2011

      @giampaolo
      Contributor

      Again, it's not clear to me what you are complaining about.
      Please try to be more clear and/or provide a patch.

    4. socketpair commented on Mar 5, 2011

      socketpairmannequin
      MannequinAuthor

      When using non-blocking IO, we issue select (or poll,epoll), and after that kernel should guarantee, that recv or send will complete immediatelly, transferring data as needed. But sometimes (as Linux is buggy), such operations results in EINTR error if some signal arrived during this call. In that case python exception generated and typically connection will be closed.
      To recover from this situation it is OK to call recv or send again in case of EINTR. All network functions (recv*, send*, accept, connect) are vulnerable for EINTR in practice.

    5. socketpair commented on Mar 5, 2011

      socketpairmannequin
      MannequinAuthor

      http://unix.derkeiler.com/Mailing-Lists/FreeBSD/hackers/2008-02/msg00457.html

      Okay, linux is not buggy :)))
      EINTR may occur if SA_RESTART is not specified in sigaction.

    6. nvetoshkin commented on Mar 5, 2011

      nvetoshkinmannequin
      Mannequin

      Here's a similar bug: http://bugs.python.org/issue7978.

      EINTR may occur if SA_RESTART is not specified in sigaction.
      Some syscalls (like select) will generate EINTR despite SA_RESTART. man 7 signal

    7. vstinner commented on Jun 27, 2014

      @vstinner
      Member

      It was already discussed in other issues, the issue is not specific to asyncore: Python code should not handle EINTR. IMO the C module socket should handle EINTR for you.

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

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions