Commit graph

9865 commits

Author SHA1 Message Date
Pablo Galindo Salgado
ded533b1fa
[3.14] gh-144316: Fix missing exception in _remote_debugging with debug=False (GH-144442) (#145280) 2026-02-26 22:39:48 +00:00
Miss Islington (bot)
12092af02e
[3.14] gh-145187: Fix crash on invalid type parameter bound expression in conditional block (GH-145188) (#145196)
gh-145187: Fix crash on invalid type parameter bound expression in conditional block (GH-145188)

Fix parsing crash found by oss-fuzz
(cherry picked from commit 5e61a16c10)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-24 21:13:08 +00:00
Miss Islington (bot)
06b6243084
[3.14] gh-145092: Fix compiler warning for memchr() and wcschr() returning const pointer (GH-145093) (GH-145102)
(cherry picked from commit faea32b729)

Co-authored-by: Rudi Heitbaum <rudi@heitbaum.com>
2026-02-22 08:28:17 +00:00
Victor Stinner
f67cf83a4e
[3.14] gh-144763: Fix race conditions in tracemalloc (#144779) (#144965)
gh-144763: Fix race conditions in tracemalloc (#144779)

Avoid PyUnstable_InterpreterFrame_GetLine() since it uses a critical
section which can lead to a deadlock.

_PyTraceMalloc_Stop() now also calls PyRefTracer_SetTracer() without
holding TABLES_LOCK() to prevent another deadlock.

(cherry picked from commit 83f4fffe3d)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-02-18 20:55:38 +01:00
Miss Islington (bot)
907958c4ba
[3.14] gh-144601: Avoid sharing exception objects raised in a PyInit function across multiple interpreters (GH-144602) (GH-144633)
gh-144601: Avoid sharing exception objects raised in a `PyInit` function across multiple interpreters (GH-144602)
(cherry picked from commit fd6b639a49)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-02-16 10:37:46 -05:00
Miss Islington (bot)
77b71ac793
[3.14] gh-144766: Fix a crash in fork child process when perf support is enabled. (GH-144795) (#144816) 2026-02-14 12:09:00 +00:00
Miss Islington (bot)
7d074702eb
[3.14] gh-143650: Fix importlib race condition on import failure (GH-143651) (#144662)
gh-143650: Fix importlib race condition on import failure (GH-143651)

Fix a race condition where a thread could receive a partially-initialized
module when another thread's import fails. The race occurs when:

1. Thread 1 starts importing, adds module to sys.modules
2. Thread 2 sees the module in sys.modules via the fast path
3. Thread 1's import fails, removes module from sys.modules
4. Thread 2 returns a stale module reference not in sys.modules

The fix adds verification after the "skip lock" optimization in both Python
and C code paths to check if the module is still in sys.modules. If the
module was removed (due to import failure), we retry the import so the
caller receives the actual exception from the import failure rather than
a stale module reference.
(cherry picked from commit ac8b5b6890)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 06:06:51 +00:00
Bartosz Sławecki
616e611844
[3.14] gh-144563: Fix remote debugging with duplicate libpython mappings from ctypes (GH-144595) (#144655) 2026-02-10 14:31:49 +00:00
Miss Islington (bot)
6006005893
[3.14] gh-144446: Fix some frame object thread-safety issues (gh-144479) (#144546)
Fix thread-safety issues when accessing frame attributes while another
thread is executing the frame:

- Add critical section to frame_repr() to prevent races when accessing
  the frame's code object and line number

- Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti()
  to allow intentional racy reads of instr_ptr.

- Fix take_ownership() to not write to the original frame's f_executable
(cherry picked from commit 5bb3bbb9c6)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-02-06 15:25:36 +00:00
Miss Islington (bot)
49ce23f2d7
[3.14] gh-144307: Fix a reference leak during module teardown (GH-144308) (GH-144327)
gh-144307: Fix a reference leak during module teardown (GH-144308)
(cherry picked from commit 219b7ac9d5)

Signed-off-by: Yongtao Huang <yongtaoh2022@gamil.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-01-29 19:19:14 +00:00
Miss Islington (bot)
157e946d78 [3.14] gh-144194: Fix mmap failure check in perf_jit_trampoline.c (GH-143713) (#144301)
gh-144194: Fix mmap failure check in perf_jit_trampoline.c (GH-143713)

mmap() returns MAP_FAILED ((void*)-1) on error, not NULL. The current
check never detects mmap failures, so jitdump initialization proceeds
even when the memory mapping fails.
(cherry picked from commit 8fe8a94a7c)

Co-authored-by: stratakis <cstratak@redhat.com>
2026-01-28 13:57:19 +00:00
Miss Islington (bot)
7ae9a479cf
[3.14] gh-144169: Fix three crashes in AST objects with non-str kwargs (GH-144178) (#144227)
gh-144169: Fix three crashes in AST objects with non-str kwargs (GH-144178)
(cherry picked from commit 639c1ad4f1)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-26 12:14:39 +00:00
Miss Islington (bot)
4f4c20412b
[3.14] gh-142779: Initialize reserved field for proper padding (GH-142780) (#144159)
gh-142779: Initialize reserved field for proper padding (GH-142780)

The jitdump specification specifies a reserved field for padding.

Initialize it so no garbage data is embedded in the jitdump files.
(cherry picked from commit 77bf4ba732)

Co-authored-by: stratakis <cstratak@redhat.com>
2026-01-25 17:44:33 +00:00
AN Long
f7567b44a1
[3.14] gh-144012: Check null binary op extend (GH-144014) (GH-144038)
(cherry picked from commit 54bedcf714)
2026-01-20 18:05:56 +00:00
Miss Islington (bot)
ae5760527a
[3.14] gh-106287: Do not write objects after an unmarshalling error (GH-132715) (GH-143832)
Writing out an object may involve a slot lookup, which is not safe to do with
an exception raised. In debug mode an assertion failure will occur if this
happens.
(cherry picked from commit ce8f5f98c6)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
2026-01-14 11:52:20 +00:00
Miss Islington (bot)
ea70d16406
[3.14] gh-143377: fix crashes in _interpreters.capture_exception (GH-143418) (#143652)
gh-143377: fix crashes in `_interpreters.capture_exception` (GH-143418)
(cherry picked from commit ce6bae92da)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-10 12:05:42 +00:00
Miss Islington (bot)
16efe85129
[3.14] gh-142829: Fix use-after-free in Context.__eq__ via re-entrant ContextVar.set (GH-142905) (#143627)
gh-142829: Fix use-after-free in `Context.__eq__` via re-entrant `ContextVar.set` (GH-142905)
(cherry picked from commit a4086d7f89)

Co-authored-by: A.Ibrahim <abdulrasheedibrahim47@gmail.com>
2026-01-10 12:21:37 +05:30
Miss Islington (bot)
fca010da50
[3.14] Fix dunder name typo in compiler code comment (GH-143374) (#143386)
Fix dunder name typo in compiler code comment (GH-143374)
(cherry picked from commit 6d05e55de0)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-01-10 12:21:09 +05:30
Victor Stinner
1d0baf1ae4
[3.14] gh-143547: Fix PyErr_FormatUnraisable() fallback (#143557) (#143603)
gh-143547: Fix PyErr_FormatUnraisable() fallback (#143557)

Hold a strong reference to 'hook' while calling the default
unraisable took to log hook failure.

(cherry picked from commit 39a2bcf949)
2026-01-09 16:10:50 +01:00
Miss Islington (bot)
6583951e7d
[3.14] gh-131421: Fix ASDL kw_defaults being expr* instead of expr?* (GH-133773) (GH-143269)
Also fix docs ASDL highlighting.
(cherry picked from commit f37f57dfe6)

Co-authored-by: Samuel <samuel@knutsen.co>
2025-12-29 12:09:11 +00:00
Pablo Galindo Salgado
892757f056
[3.14] gh-143228: Fix UAF in perf trampoline during finalization (GH-143233) (#143247) 2025-12-28 14:32:11 +00:00
Miss Islington (bot)
8a61b71eee
[3.14] gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156) (GH-143175)
gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156)
(cherry picked from commit 8611f74e08)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-12-25 12:00:42 -05:00
Miss Islington (bot)
73c40bb8ba
[3.14] gh-143135: Fix sys.flags.inspect when PYTHONINSPECT=0 (GH-143136) (GH-143153)
(cherry picked from commit 3509fa5a12)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-12-24 18:23:41 +00:00
Miss Islington (bot)
98f6db7e82
[3.14] gh-143057: avoid locking in tracemalloc C-APIs when it is not enabled (GH-143065) (#143071)
gh-143057: avoid locking in `tracemalloc` C-APIs when it is not enabled (GH-143065)
(cherry picked from commit e728b006de)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-12-22 16:04:24 +00:00
stratakis
dcbde6b792
[3.14] gh-142776: Ensure fp file descriptor is closed on all code paths in import.c (GH-142777) (#142988)
gh-142776: Ensure fp file descriptor is closed on all code paths in import.c (GH-142777)

(cherry picked from commit 6a4f10325d)
2025-12-20 12:49:23 +05:30
Miss Islington (bot)
7134b407dc
[3.14] GH-100964: Fix reference cycle in exhausted generator frames (GH-141112) (#142902)
GH-100964: Fix reference cycle in exhausted generator frames (GH-141112)
(cherry picked from commit 92243dc62c)

Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-12-17 19:48:18 +00:00
Miss Islington (bot)
338bdb2415
[3.14] gh-142873: Do not check for PyContextVar_CheckExact twice in PyContextVar_Set (GH-142874) (#142893)
gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (GH-142874)
(cherry picked from commit e61a447d0e)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-12-17 18:28:37 +00:00
Miss Islington (bot)
b9cbdde80d
[3.14] gh-142737: Handle lost io.open in _Py_FindSourceFile (GH-142747) (GH-142773)
gh-142737: Handle lost `io.open` in `_Py_FindSourceFile` (GH-142747)
(cherry picked from commit f277781bba)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-12-15 23:30:00 +00:00
Neil Schemenauer
27f27a68b3
[3.14] gh-142531: Fix free-threaded GC performance regression (gh-142562) (gh-142617)
If there are many untracked tuples, the GC will run too often, resulting
in poor performance.  The fix is to include untracked tuples in the
"long lived" object count. The number of frozen objects is also now
included since the free-threaded GC must scan those too.
(cherry picked from commit e38967ed60)
2025-12-12 14:30:20 -08:00
Miss Islington (bot)
ebeb07f132
[3.14] gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548) (GH-142301)
(cherry picked from commit 706fdda8b3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-12 15:11:43 +00:00
Miss Islington (bot)
8e496013b2
[3.14] gh-142627: Ignore anonymous mappings in Linux remote debugging (GH-142628) (#142630)
gh-142627: Ignore anonymous mappings in Linux remote debugging (GH-142628)
(cherry picked from commit e0bca091a4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-12 13:38:09 +00:00
Miss Islington (bot)
c3fbe286c0
[3.14] gh-142571: Check for errors before calling each syscall in PyUnstable_CopyPerfMapFile() (GH-142460) (#142600)
Co-authored-by: AZero13 <gfunni234@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-12-11 22:13:36 +00:00
Miss Islington (bot)
acd5b97082
[3.14] gh-137007: Track executor before any possible deallocations (GH-137016) (GH-142541)
gh-137007: Track executor before any possible deallocations (GH-137016)
(cherry picked from commit 97e19014dd)

Co-authored-by: Ken Jin <kenjin@python.org>
2025-12-10 22:54:28 +00:00
Miss Islington (bot)
0114178911
[3.14] gh-142048: Fix lost gc allocations count on thread cleanup (GH-142233) (#142504)
gh-142048: Fix lost gc allocations count on thread cleanup (GH-142233)
(cherry picked from commit 49b1fb43f6)

Co-authored-by: Kevin Wang <kevmo314@gmail.com>
2025-12-10 10:52:55 +00:00
Miss Islington (bot)
5c5670eb45
[3.14] gh-142048: Fix quadratically increasing GC delays (gh-142051) (gh-142166)
The GC for the free threaded build would get slower with each collection due
to effectively double counting objects freed by the GC.
(cherry picked from commit eb892868b3)

Co-authored-by: Kevin Wang <kevmo314@gmail.com>
2025-12-02 00:30:11 +00:00
Hugo van Kemenade
7642070807
[3.14] Revert "GH-91636: Clear weakrefs created by finalizers. (GH-136401) (#141993)" (#142152) 2025-12-01 20:34:37 +02:00
Miss Islington (bot)
52731c4e62
[3.14] gh-140373: Correctly emit PY_UNWIND event when generator is closed (GH-140767) (#140816)
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-11-30 14:35:14 +02:00
Miss Islington (bot)
fed2af6f9e
[3.14] GH-91636: Clear weakrefs created by finalizers. (GH-136401) (#141993)
GH-91636: Clear weakrefs created by finalizers. (GH-136401)

Weakrefs to unreachable garbage that are created during running of
finalizers need to be cleared.  This avoids exposing objects that
have `tp_clear` called on them to Python-level code.
(cherry picked from commit b6b99bf7f1)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2025-11-28 23:34:36 -08:00
Itamar Oren
f7d17ac9f8
[3.14] gh-140011: Delete importdl assertion that prevents importing embedded modules from packages (GH-141605) (#141986)
gh-140011: Delete importdl assertion that prevents importing embedded modules from packages (GH-141605)

(cherry picked from commit 27f62eb711)
2025-11-28 23:30:57 -08:00
Miss Islington (bot)
a1dd248022
[3.14] gh-116008: Detect freed thread state in faulthandler (GH-141988) (#142013)
gh-116008: Detect freed thread state in faulthandler (GH-141988)

Add _PyMem_IsULongFreed() function.
(cherry picked from commit d5d9e89dde)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-27 20:34:00 +00:00
Victor Stinner
ad60d8963e
[3.14] gh-125434: Display thread name in faulthandler on Windows (#142011)
* gh-125434: Display thread name in faulthandler on Windows (#140675)

(cherry picked from commit 313145eab5)

* gh-125434: Fix non-ASCII thread names in faulthandler on Windows (#140700)

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().

(cherry picked from commit 80f20f58b2)
2025-11-27 12:05:37 +00:00
Petr Viktorin
69021e9acf
[3.14] GH-139653: Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack. (GH-141711) (GH-141944)
Only raises if the stack pointer is both below the limit *and* above the stack base.
This prevents false positives for user-space threads, as the stack pointer will be outside those bounds
if the stack has been swapped.

Cherry-picked from commit c25a070759

Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-11-26 12:54:56 +01:00
Petr Viktorin
32a38a2523
[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) (#141661)
Co-authored-by: Rok Mandeljc <rok.mandeljc@gmail.com>
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-25 14:21:53 +01:00
Stefano Rivera
394db662a5
[3.14] GH-139914: Handle stack growth direction on HPPA (GH-140028) (#141404)
* [3.14] GH-139914: Handle stack growth direction on HPPA (GH-140028)

Adapted from a patch for Python 3.14 submitted to the Debian BTS by John David Anglin https://bugs.debian.org/1105111#20

* Forgot to update test_call

* WTF typo
2025-11-23 15:55:33 -08:00
Miss Islington (bot)
1a798d30d8
[3.14] gh-120158: Fix inconsistent monitoring state when setting events too frequently (gh-141845) (gh-141879)
If we overflowed the global version counter (i.e., after 2*24 calls to
`_PyMonitoring_SetEvents`), we bailed out after setting global monitoring
events but before instrumenting code objects, which led to assertion errors
later on.

Also add a `time.sleep()` to `test_free_threading.test_monitoring` to avoid
overflowing the global version counter.
(cherry picked from commit e457d60daa)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-11-23 15:31:56 +00:00
Miss Islington (bot)
5bca7f4d7a
[3.14] gh-137422: Fix race condition in PyImport_AddModuleRef (gh-141822) (gh-141830)
(cherry picked from commit 2d50dd242e)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-11-21 18:57:30 +00:00
Sergey Miryanov
21e43d5e83
[3.14] GH-141509: Fix warning about remaining subinterpreters (GH-141528) (GH-141566)
(cherry picked from commit fa245df4a0)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-15 13:56:52 -05:00
Miss Islington (bot)
17e7aad5e3
[3.14] gh-141579: Fix perf_jit backend in sys.activate_stack_trampoline() (GH-141580) (#141581)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-11-15 02:49:54 +00:00
Miss Islington (bot)
1cde019ecd
[3.14] gh-114203: skip locking if object is already locked by two-mutex critical section (GH-141476) (#141564)
gh-114203: skip locking if object is already locked by two-mutex critical section (GH-141476)
(cherry picked from commit f26ed455d5)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-14 18:38:30 +00:00
Mikhail Efimov
af20b880fc
[3.14] gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233) (GH-141495) 2025-11-13 18:47:25 +00:00