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

Remove _Py_CheckRecursionLimit variable #86000

Closed
vstinner opened this issue Sep 22, 2020 · 2 comments
Closed

Remove _Py_CheckRecursionLimit variable #86000

vstinner opened this issue Sep 22, 2020 · 2 comments

Comments

@vstinner
Copy link
Member

@vstinner vstinner commented Sep 22, 2020

BPO 41834
Nosy @vstinner
PRs
  • #22359
  • 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-10-01.22:45:53.405>
    created_at = <Date 2020-09-22.12:39:27.492>
    labels = ['expert-C-API', '3.10']
    title = 'Remove _Py_CheckRecursionLimit variable'
    updated_at = <Date 2020-10-01.22:45:53.404>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-10-01.22:45:53.404>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-01.22:45:53.405>
    closer = 'vstinner'
    components = ['C API']
    creation = <Date 2020-09-22.12:39:27.492>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41834
    keywords = ['patch']
    message_count = 2.0
    messages = ['377317', '377367']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['22359']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue41834'
    versions = ['Python 3.10']

    @vstinner
    Copy link
    Member Author

    @vstinner vstinner commented Sep 22, 2020

    _Py_CheckRecursionLimit variable is no longer needed and can be removed.

    In Python 3.9, I added a recursion limit per interpreter.

    In Python 3.8 and older, it was used by _Py_MakeRecCheck() macro to check for recursion error.

    Previously, the _Py_CheckRecursionLimit variable was kept for backward compatibility with the stable ABI, but in Python 3.8 and older, Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() could not be used with the limited C API since these macros accessed PyThreadState structure member, whereas the structure is opaque in the limited C API.

    Attached PR removed the variable.

    ---

    (3) bpo-40513: Limit made per interpreter.

    commit 4e30ed3
    Author: Victor Stinner <vstinner@python.org>
    Date: Tue May 5 16:52:52 2020 +0200

    bpo-40513: Per-interpreter recursion_limit (GH-19929)
    
    Move recursion_limit member from _PyRuntimeState.ceval to
    PyInterpreterState.ceval.
    
    * Py_SetRecursionLimit() now only sets _Py_CheckRecursionLimit
      of ceval.c if the current Python thread is part of the main
      interpreter.
    * Inline _Py_MakeEndRecCheck() into _Py_LeaveRecursiveCall().
    * Convert _Py_RecursionLimitLowerWaterMark() macro into a static
      inline function.
    

    ---

    (2) bpo-38644: The _Py_CheckRecursionLimit variable was used by Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros. I converted these macros into function calls in Python 3.9:

    commit f4b1e3d
    Author: Victor Stinner <vstinner@python.org>
    Date: Mon Nov 4 19:48:34 2019 +0100

    bpo-38644: Add Py_EnterRecursiveCall() to the limited API (GH-17046)
    
    Provide Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() as
    regular functions for the limited API. Previously, there were defined
    as macros, but these macros didn't work with the limited API which
    cannot access PyThreadState.recursion_depth field.
    
    Remove _Py_CheckRecursionLimit from the stable ABI.
    
    Add [Include/cpython/ceval.h](https://github.com/python/cpython/blob/main/Include/cpython/ceval.h) header file.
    

    In pycore_ceval.h, the function is overriden by a macro which points to an inline function which uses:

    • tstate->recursion_depth
    • tstate->interp->ceval.recursion_limit
    • tstate->stackcheck_counter (if USE_STACKCHECK macro is defined)

    ---

    (1) bpo-31857: Original change adding the FIXME.

    commit 1896793
    Author: pdox <pdox@alum.mit.edu>
    Date: Wed Oct 25 23:03:01 2017 -0700

    bpo-31857: Make the behavior of USE_STACKCHECK deterministic (bpo-4098)
    

    This change added the FIXME comment:

    /* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
    the stable ABI. It should be removed therefrom when possible.
    */

    @vstinner
    Copy link
    Member Author

    @vstinner vstinner commented Sep 23, 2020

    New changeset 19c3ac9 by Victor Stinner in branch 'master':
    bpo-41834: Remove _Py_CheckRecursionLimit variable (GH-22359)
    19c3ac9

    @vstinner vstinner closed this as completed Oct 1, 2020
    @vstinner vstinner closed this as completed Oct 1, 2020
    @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
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant