Skip to content

subprocess with preexec_fn when fork() fails could corrupt PyErr state #78839

Closed

Description

@gpshead
BPO 34658
Nosy @gpshead, @miss-islington
PRs
  • bpo-34658: Fix rare subprocess prexec_fn fork error. #9255
  • [3.7] bpo-34658: Fix rare subprocess prexec_fn fork error. (GH-9255) #9256
  • [3.6] bpo-34658: Fix rare subprocess prexec_fn fork error. (GH-9255) #9292
  • 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 = 'https://github.com/gpshead'
    closed_at = <Date 2018-09-14.05:24:27.467>
    created_at = <Date 2018-09-13.10:57:27.885>
    labels = ['extension-modules', '3.8', 'type-bug', '3.7']
    title = 'subprocess with preexec_fn when fork() fails could corrupt PyErr state'
    updated_at = <Date 2018-09-14.05:24:27.465>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2018-09-14.05:24:27.465>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2018-09-14.05:24:27.467>
    closer = 'gregory.p.smith'
    components = ['Extension Modules']
    creation = <Date 2018-09-13.10:57:27.885>
    creator = 'gregory.p.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34658
    keywords = ['patch']
    message_count = 3.0
    messages = ['325238', '325239', '325265']
    nosy_count = 2.0
    nosy_names = ['gregory.p.smith', 'miss-islington']
    pr_nums = ['9255', '9256', '9292']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34658'
    versions = ['Python 3.7', 'Python 3.8']

    Activity

    1. gpshead commented on Sep 13, 2018

      @gpshead
      MemberAuthor

      Found in the stdlib test suite while testing the fix for bpo-6721: When subprocess is called with a preexec_fn and os.register_at_fork has been used and the fork() system call fails, the Python error state is set before the "after fork in parent process" function calls that were registered were called. So they'd call back into Python code with a pending unreturned exception set.

      boom. SystemError (or assertion failure in pydebug builds).

    2. self-assigned this
      on Sep 13, 2018
    3. miss-islington commented on Sep 13, 2018

      @miss-islington
      Contributor

      New changeset a20b6ad by Miss Islington (bot) (Gregory P. Smith) in branch 'master':
      bpo-34658: Fix rare subprocess prexec_fn fork error. (GH-9255)
      a20b6ad

    4. miss-islington commented on Sep 13, 2018

      @miss-islington
      Contributor

      New changeset b2ff9a9 by Miss Islington (bot) in branch '3.7':
      bpo-34658: Fix rare subprocess prexec_fn fork error. (GH-9255)
      b2ff9a9

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

    Labels

    3.7 (EOL)end of life3.8 (EOL)end of lifeextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions