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

Calling os.fork() at Python exit logs: AttributeError: 'NoneType' object has no attribute '_at_fork_reinit' #86516

Closed
vstinner opened this issue Nov 13, 2020 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@vstinner
Copy link
Member

BPO 42350
Nosy @vstinner, @miss-islington
PRs
  • bpo-42350: Fix Thread._reset_internal_locks() #23268
  • [3.9] bpo-42350: Fix Thread._reset_internal_locks() (GH-23268) #23315
  • 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 2020-11-16.15:18:33.276>
    created_at = <Date 2020-11-13.17:51:36.075>
    labels = ['library', '3.9', '3.10']
    title = "Calling os.fork() at Python exit logs: AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'"
    updated_at = <Date 2020-11-16.15:18:33.275>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-11-16.15:18:33.275>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-16.15:18:33.276>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2020-11-13.17:51:36.075>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42350
    keywords = ['patch']
    message_count = 3.0
    messages = ['380912', '381099', '381109']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'miss-islington']
    pr_nums = ['23268', '23315']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue42350'
    versions = ['Python 3.9', 'Python 3.10']

    @vstinner
    Copy link
    Member Author

    The following code logs an error:
    ---

    Exception ignored in: <function _after_fork at 0x7f2bf3b057e0>
    Traceback (most recent call last):
      File "/home/vstinner/python/master/Lib/threading.py", line 1508, in _after_fork
        thread._reset_internal_locks(True)
      File "/home/vstinner/python/master/Lib/threading.py", line 847, in _reset_internal_locks
        self._tstate_lock._at_fork_reinit()
    AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'

    Code:
    ---

    #!/usr/bin/python3
    import atexit
    import subprocess
    
    
    def preexec():
        pass
    
    
    def exit_handler():
        proc = subprocess.Popen(
            ["pwd"],
            preexec_fn=preexec,
        )
        proc.communicate()
    
    
    if __name__ == "__main__":
        atexit.register(exit_handler)

    It is a regression caused by the following bpo-40089 fix:

    commit 87255be
    Author: Victor Stinner <vstinner@python.org>
    Date: Tue Apr 7 23:11:49 2020 +0200

    bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)
    

    @vstinner vstinner added 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir labels Nov 13, 2020
    @vstinner
    Copy link
    Member Author

    New changeset 5909a49 by Victor Stinner in branch 'master':
    bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)
    5909a49

    @miss-islington
    Copy link
    Contributor

    New changeset cf70854 by Miss Islington (bot) in branch '3.9':
    bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)
    cf70854

    @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.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants