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

Crash in _PyXI_ApplyErrorCode() #126986

Closed
ericsnowcurrently opened this issue Nov 18, 2024 · 1 comment
Closed

Crash in _PyXI_ApplyErrorCode() #126986

ericsnowcurrently opened this issue Nov 18, 2024 · 1 comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Nov 18, 2024

Crash report

Bug description:

This is a problem in Python/crossinterp.c, as exposed by the _interpreters module.

reproducer:

  1. interp is running as "main" in thread 1
  2. thread 2 calls _PyXI_Enter(), which emits the _PyXI_ERR_ALREADY_RUNNING error code
  3. thread 1 finishes
  4. thread 2 calls _PyXI_ApplyError()
  5. _PyXI_ApplyError() calls _PyInterpreterState_FailIfNotRunning() to raise the exception, but it doesn't raise anything

I noticed this while working on gh-126914.

CPython versions tested on:

3.14

Operating systems tested on:

No response

Linked PRs

@ericsnowcurrently ericsnowcurrently added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump topic-subinterpreters 3.14 new features, bugs and security fixes labels Nov 18, 2024
ericsnowcurrently added a commit that referenced this issue Nov 19, 2024
We replace it with _PyErr_SetInterpreterAlreadyRunning().
@ZeroIntensity
Copy link
Member

Affecting 3.13(t) as well:

$ ./python x.py
python: Python/crossinterp.c:988: _PyXI_ApplyErrorCode: Assertion `_PyInterpreterState_IsRunningMain(interp)' failed.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 19, 2024
…h-126988)

We replace it with _PyErr_SetInterpreterAlreadyRunning().
(cherry picked from commit d6b3e78)

Co-authored-by: Eric Snow <[email protected]>
@ZeroIntensity ZeroIntensity added the 3.13 bugs and security fixes label Nov 19, 2024
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this issue Nov 21, 2024
…h-126988)

We replace it with _PyErr_SetInterpreterAlreadyRunning().
ericsnowcurrently added a commit that referenced this issue Nov 21, 2024
…h-127112)

This is a pseudo-backport of d6b3e78 (gh-126988).  In that change for 3.14+, we dropped _PyInterpreterState_FailIfNotRunning() and added _PyErr_SetInterpreterAlreadyRunning().  Here, we replace usage of _PyInterpreterState_FailIfNotRunning() with the inlined equivalent of _PyErr_SetInterpreterAlreadyRunning(), without adding that function.  That way we avoid changing the 3.13 ABI.
@github-project-automation github-project-automation bot moved this from Todo to Done in Subinterpreters Nov 21, 2024
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
…h-126988)

We replace it with _PyErr_SetInterpreterAlreadyRunning().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump
Projects
Status: Done
Development

No branches or pull requests

2 participants