GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CPython should not assume that pthread_self returns the same value in fork parent and child · Issue #126688 · python/cpython

CPython should not assume that pthread_self returns the same value in fork parent and child #126688

New issue
Copy link
New issue
Copy link
Closed
Closed
CPython should not assume that pthread_self returns the same value in fork parent and child#126688
Copy link
Assignees
colesbury
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@nico
nico
opened on Nov 11, 2024
Issue body actions

Summarized from SerenityOS/serenity#25263 by request of @colesbury:

It seems that at least Python 3.13 relies on pthread_self returning the same value in both the parent and the child process.
PyThread_get_thread_ident_ex

POSIX doesn't seem to mention if the value returned by pthread_self should be inherited by the child process.
pthread_self
fork

(It is the case on Linux, Hurd, FreeBSD, OpenBSD, Cygwin. It isn't on SerenityOS, and also not on Solaris 9/HP-UX 11 per https://bugs.python.org/issue7242.

It looks like the code add broke things is from this commit e21057b added in #118523 as part of #117657

Linked PRs

  • gh-126688: Reinit import lock after fork #126692
  • [3.13] gh-126688: Reinit import lock after fork (GH-126692) #126765
  • gh-126688: Support Fork Parent and Child With Different Thread ID #127121
Reacted by Gregory P. Smith

Activity

  1. colesbury
    self-assigned this
    on Nov 11, 2024
  2. colesbury
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Nov 11, 2024
  3. colesbury
    added 4 commits that reference this issue on Nov 11, 2024

    pythongh-126688: Reinit import lock after fork

    fc4bdfb

    pythongh-126688: Reinit import lock after fork

    5e86cca

    Merge branch 'main' into pythongh-126688-import-lock

    4bf74b8

    gh-126688: Reinit import lock after fork (#126692)

    5610860
  4. miss-islington
    added a commit that references this issue on Nov 12, 2024

    pythongh-126688: Reinit import lock after fork (pythonGH-126692)

    6f77b81
  5. colesbury
    added a commit that references this issue on Nov 12, 2024

    [3.13] gh-126688: Reinit import lock after fork (GH-126692) (GH-126765)

    13fe8f9
  6. oskar-skog commented on Nov 12, 2024

    @oskar-skog
    oskar-skog
    on Nov 12, 2024
    More actions

    I think this can be closed now.

  7. colesbury
    closed this as completedon Nov 12, 2024
  8. ericsnowcurrently commented on Nov 21, 2024

    @ericsnowcurrently
    ericsnowcurrently
    on Nov 21, 2024
    Member
    More actions

    There may be other code that makes the same assumption about the thread ID. For example, in PyOS_AfterFork_Child():

    cpython/Modules/posixmodule.c

    Lines 655 to 658 in 09c240f

    assert(tstate->thread_id == PyThread_get_thread_ident());
    #ifdef PY_HAVE_THREAD_NATIVE_ID
    tstate->native_thread_id = PyThread_get_thread_native_id();
    #endif

    This would break only on debug builds (or at least !defined(NDEBUG)).

    I'm guessing there are other places too.

  9. picnixz
    added a commit that references this issue on Dec 8, 2024

    pythongh-126688: Reinit import lock after fork (python#126692)

    45320c2
  10. ebonnal
    added a commit that references this issue on Jan 12, 2025

    pythongh-126688: Reinit import lock after fork (python#126692)

    6b28e03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @colesbury
    colesbury

Labels

3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.