Skip to content

Fatal Python error from warnings._release_lock() #129766

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
devdanzin opened this issue Feb 7, 2025 · 3 comments
Closed

Fatal Python error from warnings._release_lock() #129766

devdanzin opened this issue Feb 7, 2025 · 3 comments
Assignees
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@devdanzin
Copy link
Contributor

devdanzin commented Feb 7, 2025

Crash report

What happened?

Exposing the mutex used by the _warnings module in #128386 has made it possible to abort the interpreter by calling warnings._release_lock():

import warnings
warnings._release_lock()

Error message:

Fatal Python error: _PyRecursiveMutex_Unlock: unlocking a recursive mutex that is not owned by the current thread
Python runtime state: initialized

Current thread 0x0000718eb9295740 (most recent call first):
  File "<string>", line 1 in <module>
Aborted (core dumped)

Found using fusil by @vstinner.

CPython versions tested on:

CPython main branch, 3.14

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a4+ (heads/main:e1006ce1de, Feb 6 2025, 17:22:01) [GCC 13.3.0]

Linked PRs

@devdanzin devdanzin added the type-crash A hard crash of the interpreter, possibly with a core dump label Feb 7, 2025
@devdanzin
Copy link
Contributor Author

cc @nascheme and @kumaraditya303

@sobolevn sobolevn self-assigned this Feb 7, 2025
@sobolevn
Copy link
Member

sobolevn commented Feb 7, 2025

We should use _PyRecursiveMutex_TryUnlock and raise RuntimeError instead, like in many other places.

@sobolevn
Copy link
Member

sobolevn commented Feb 7, 2025

Fixed! Thanks for the report.

@sobolevn sobolevn closed this as completed Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants