Skip to content

PyThreadState_IsCurrent bug under building Python with --with-experimental-isolated-subinterpreters #88540

Description

@JunyiXie
mannequin
BPO 44374
Nosy @vstinner, @junyixie

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 = None
created_at = <Date 2021-06-10.10:14:52.708>
labels = ['expert-subinterpreters', '3.11']
title = 'PyThreadState_IsCurrent bug under building Python with --with-experimental-isolated-subinterpreters'
updated_at = <Date 2021-06-10.10:14:52.708>
user = 'https://github.com/JunyiXie'

bugs.python.org fields:

activity = <Date 2021-06-10.10:14:52.708>
actor = 'JunyiXie'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Subinterpreters']
creation = <Date 2021-06-10.10:14:52.708>
creator = 'JunyiXie'
dependencies = []
files = []
hgrepos = []
issue_num = 44374
keywords = []
message_count = 1.0
messages = ['395517']
nosy_count = 2.0
nosy_names = ['vstinner', 'JunyiXie']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44374'
versions = ['Python 3.11']

Activity

  1. JunyiXie commented on Jun 10, 2021

    JunyiXiemannequin
    MannequinAuthor

    under building Python with --with-experimental-isolated-subinterpreters
    PyThreadState_IsCurrent use _PyRuntime.gilstate. is shared by multi sub interpreters.
    Use interpreter gil->last_holder == state can fix it?

    static int
    PyThreadState_IsCurrent(PyThreadState *tstate)
    {
        /* Must be the tstate for this thread */
        struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
        assert(_PyGILState_GetThisThreadState(gilstate) == tstate);
        return tstate == _PyRuntimeGILState_GetThreadState(gilstate);
    }
    
    static int
    PyThreadState_IsCurrent(PyThreadState *tstate)
    {
    #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
        PyInterpreterState *interp = tstate->interp;
        struct _ceval_state *ceval2 = &interp->ceval;
        struct _gil_runtime_state *gil = &ceval2->gil;
        return tstate == (PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder);
    #else
        /* Must be the tstate for this thread */
        struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
        assert(_PyGILState_GetThisThreadState(gilstate) == tstate);
        return tstate == _PyRuntimeGILState_GetThreadState(gilstate);
    #endif
    }
    
  2. transferred this issue fromon Apr 10, 2022
  3. kumaraditya303 commented on Jul 10, 2022

    @kumaraditya303
    Contributor

    Closing as EXPERIMENTAL_ISOLATED_SUBINTERPRETERS was removed in #93185

  4. Repository owner moved this from Todo to Done in Subinterpreterson Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions