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

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

Closed
gpshead opened this issue Sep 13, 2018 · 3 comments
Closed

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

gpshead opened this issue Sep 13, 2018 · 3 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@gpshead
Copy link
Member

gpshead commented Sep 13, 2018

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']

    @gpshead
    Copy link
    Member Author

    gpshead commented Sep 13, 2018

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

    @gpshead gpshead added 3.7 (EOL) end of life 3.8 only security fixes labels Sep 13, 2018
    @gpshead gpshead self-assigned this Sep 13, 2018
    @gpshead gpshead added type-bug An unexpected behavior, bug, or error extension-modules C modules in the Modules dir labels Sep 13, 2018
    @miss-islington
    Copy link
    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

    @miss-islington
    Copy link
    Contributor

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

    @gpshead gpshead closed this as completed Sep 14, 2018
    @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.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants