Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thenative_thread_id field ofPyThreadState is not updated after fork #100649

Closed
Labels
3.11only security fixestype-bugAn unexpected behavior, bug, or error
@P403n1x87

Description

@P403n1x87

Bug report

Thenative_thread_id field of thePyThreadState object is not updated after a fork on Linux (at least). This means that child processes spawned by the main thread of the parent process will have a main thread with the parent thread ID.

Thenative_thread_id is meant to be consumed by tools likeAustin and therefore the behaviour is easily observed with these tools. One way to reproduce this is to profile this with Austin

importmultiprocessingdeffact(n):f=1foriinrange(1,n+1):f*=ireturnfdefdo(N):n=1for_inrange(N):fact(n)n+=1if__name__=="__main__":importsystry:nproc=int(sys.argv[1])exceptException:nproc=2processes= []for_inrange(nproc):process=multiprocessing.Process(target=do,args=(3000,))process.start()processes.append(process)forprocessinprocesses:process.join(timeout=5)

and observe that the reported thread IDs coincide with the parent's PID.

Your environment

  • CPython versions tested on: 3.11.1
  • Operating system and architecture: Ubuntu 22.04 (amd64)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp