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 — Some Runtime Finalization Constraints Are Not Enforced Nor Documented · Issue #120838 · python/cpython

Some Runtime Finalization Constraints Are Not Enforced Nor Documented #120838

New issue
Copy link
New issue
Copy link
Open
Open
Some Runtime Finalization Constraints Are Not Enforced Nor Documented#120838
Copy link
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@ericsnowcurrently
ericsnowcurrently
opened on Jun 21, 2024
Issue body actions

Bug report

Bug description:

There are a few technical constraints on calling Py_Finalize() currently aren't enforced, well-documented, or widely recognized. This is partly due to the relatively small number of embedders and the even smaller number of them that might violate the constraints through the use of threads or subinterpreters.

The constraints are:

  • should be called only in the main thread
  • should be called only with the main interpreter active
  • should be called only using the same thread state used for Py_Initialize()

(That last one is potentially less critical.)

There are several reasons these matter:

  • the main thread of the main interpreter has a special role in the runtime's lifecycle
  • the main thread of the main interpreter has unique responsibilities that must be synchronized with finalization
  • conceptually, runtime lifecycle is an app-level function, and the app is typically driven through the "main" thread

The constraints should be documented, tested, and (possibly) enforced.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

  • gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() #120839
  • gh-120838: Add Tests For "Bad" Usage in Runtime Lifecycle Operations #120840
  • gh-120838: Disallow Py_Finalize() if Py_RunMain() is Running #120841
  • [3.13] gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (gh-120839) #120852
  • [3.12] gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (gh-120839) #120853
  • gh-120838: Add _PyThreadState_WHENCE_FINI #121010
  • [3.13] gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121010) #121013
  • gh-120838: Make Sure Py_Finalize() Always Runs Against the Main Interpreter #121063

Activity

  1. ericsnowcurrently
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-C-API
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Jun 21, 2024
  2. ericsnowcurrently
    added a commit that references this issue on Jun 21, 2024

    gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (

    03fa2df
  3. miss-islington
    added 2 commits that reference this issue on Jun 21, 2024

    pythongh-120838: Add a Note in the Docs About Expectations for Py_Fin…

    bf8483d

    pythongh-120838: Add a Note in the Docs About Expectations for Py_Fin…

    f743c96
  4. ericsnowcurrently
    added 3 commits that reference this issue on Jun 21, 2024

    [3.12] gh-120838: Add a Note in the Docs About Expectations for Py_Fi…

    a57d917

    [3.13] gh-120838: Add a Note in the Docs About Expectations for Py_Fi…

    e748805

    gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121010)

    a905721
  5. miss-islington
    added a commit that references this issue on Jun 25, 2024

    pythongh-120838: Add _PyThreadState_WHENCE_FINI (pythongh-121010)

    b82a961
  6. ericsnowcurrently
    added a commit that references this issue on Jun 26, 2024

    [3.13] gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121013)

    c052b19
  7. mrahtz
    added 2 commits that reference this issue on Jun 30, 2024

    pythongh-120838: Add a Note in the Docs About Expectations for Py_Fin…

    effface

    pythongh-120838: Add _PyThreadState_WHENCE_FINI (pythongh-121010)

    0e87b73
  8. estyxx
    added 2 commits that reference this issue on Jul 17, 2024

    pythongh-120838: Add a Note in the Docs About Expectations for Py_Fin…

    0018317

    pythongh-120838: Add _PyThreadState_WHENCE_FINI (pythongh-121010)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-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.