Skip to content

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

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

Closed
JunyiXie mannequin opened this issue Jun 10, 2021 · 2 comments
Labels

Comments

@JunyiXie
Copy link
Mannequin

JunyiXie mannequin commented Jun 10, 2021

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']

@JunyiXie
Copy link
Mannequin Author

JunyiXie mannequin commented Jun 10, 2021

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
}

@JunyiXie JunyiXie mannequin added 3.11 only security fixes topic-subinterpreters labels Jun 10, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@ezio-melotti ezio-melotti moved this to Todo in Subinterpreters Apr 15, 2022
@kumaraditya303
Copy link
Contributor

Closing as EXPERIMENTAL_ISOLATED_SUBINTERPRETERS was removed in #93185

@kumaraditya303 kumaraditya303 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2022
Repository owner moved this from Todo to Done in Subinterpreters Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

1 participant