cpython/Python
Miss Islington (bot) 48b1e6026b
[3.14] gh-159652: Fix import lock leak when the C stack is nearly exhausted (GH-159660) (GH-160780)
gh-159652: Fix import lock leak when the C stack is nearly exhausted (GH-159660)

When an import failed with a stack overflow RecursionError, releasing the import locks on the error path could itself raise RecursionError, because the cleanup runs in a new C frame. This left the global import lock or a module lock held forever, and later imports in other threads blocked indefinitely.

_imp.acquire_lock() now raises RecursionError when there is not enough stack left to release the lock. importlib calls it before taking any import lock, so this covers the per-module locks too. The module lock weakref callback skips cleanup in that case instead of
reporting an unraisable exception.
(cherry picked from commit 926b0bf311)

Co-authored-by: Cary Hawkins <hawkinscary23@gmail.com>
2026-10-27 22:12:45 +00:00
..
clinic
frozen_modules
_contextvars.c
_warnings.c [3.14] gh-159739: Fix reference and error handling in warnings (GH-159758) (#160085) 2026-10-21 19:24:15 +00:00
asdl.c
asm_trampoline.S [3.14] gh-128883: Store ELF perf trampoline templates in read-only data (GH-160366) (#160492) 2026-10-23 20:56:21 +00:00
asm_trampoline_aarch64.h
assemble.c
ast.c
ast_preprocess.c
ast_unparse.c
bltinmodule.c
bootstrap_hash.c
brc.c
bytecodes.c
ceval.c
ceval_gil.c
ceval_macros.h
codecs.c [3.14] gh-159739: Hold the codec registry lock while unregistering (GH-160168) (#160485) 2026-10-24 13:43:43 -07:00
codegen.c [3.14] gh-156466: fix cleanup on error in codegen_function_body (GH-156511) (#156579) 2026-10-25 16:01:30 +02:00
compile.c [3.14] gh-156459: Fix cleanup on error in compiler_set_qualname (GH-156462) (#156575) 2026-10-23 20:35:42 +03:00
condvar.h
config_common.h
context.c [3.14] gh-159739: Preserve ContextVar cache updates from finalizers (GH-160197) (#160329) 2026-10-22 15:22:13 -07:00
critical_section.c
crossinterp.c
crossinterp_data_lookup.h
crossinterp_exceptions.h
dtoa.c
dup2.c
dynamic_annotations.c
dynload_hpux.c
dynload_shlib.c
dynload_stub.c
dynload_win.c
emscripten_signal.c
emscripten_syscalls.c
emscripten_trampoline.c
emscripten_trampoline_inner.c
errors.c
executor_cases.c.h
fileutils.c
flowgraph.c
formatter_unicode.c [3.14] gh-159739: Check character formatting allocation failure (GH-159746) (#159840) 2026-10-20 08:45:25 -07:00
frame.c
frozen.c
frozenmain.c
future.c
gc.c
gc_free_threading.c [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160183) 2026-10-22 09:54:37 -07:00
gc_gil.c
generated_cases.c.h
getargs.c
getcompiler.c
getcopyright.c
getopt.c
getplatform.c
getversion.c
hamt.c
hashtable.c
import.c [3.14] gh-159652: Fix import lock leak when the C stack is nearly exhausted (GH-159660) (GH-160780) 2026-10-27 22:12:45 +00:00
importdl.c
index_pool.c
initconfig.c [3.14] gh-159739: Release replaced PyInitConfig strings (GH-159769) (#159810) 2026-10-20 00:32:57 +00:00
instruction_sequence.c
instrumentation.c [3.14] gh-158121: Preserve instruction events when line monitoring is… (#159741) 2026-10-19 14:19:52 -07:00
interpconfig.c [3.14] gh-159739: Handle interpreter configuration encoding errors (GH-159747) (#159844) 2026-10-20 11:12:29 -07:00
intrinsics.c
jit.c
legacy_tracing.c
lock.c [3.14] gh-158973: Reset the warnings lock after fork in the child (gh-158974) (gh-159615) 2026-10-20 00:06:42 +00:00
marshal.c [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160183) 2026-10-22 09:54:37 -07:00
modsupport.c
mysnprintf.c
mystrtoul.c
object_stack.c
opcode_targets.h
optimizer.c
optimizer_analysis.c
optimizer_bytecodes.c
optimizer_cases.c.h
optimizer_symbols.c
parking_lot.c
pathconfig.c
perf_jit_trampoline.c
perf_trampoline.c
preconfig.c
pyarena.c
pyctype.c
pyfpe.c
pyhash.c
pylifecycle.c [3.14] Fix ignored error returns in sys initialization, _ctypes and _interpchannels (GH-160614) (#160712) 2026-10-26 19:49:48 +00:00
pymath.c
pystate.c [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160183) 2026-10-22 09:54:37 -07:00
pystrcmp.c
pystrhex.c
pystrtod.c
Python-ast.c
Python-tokenize.c
pythonrun.c
pytime.c
qsbr.c
README
remote_debug.h
remote_debugging.c
specialize.c
stackrefs.c
stdlib_module_names.h
structmember.c
suggestions.c
symtable.c [3.14] gh-160299: Preserve references from inlined comprehensions (GH-160413) (#160457) 2026-10-23 18:31:06 +00:00
sysmodule.c
thread.c
thread_nt.h
thread_pthread.h
thread_pthread_stubs.h
tier2_engine.md
traceback.c
tracemalloc.c
uniqueid.c
vm-state.md

Miscellaneous source files for the main Python shared library