Commit graph

9842 commits

Author SHA1 Message Date
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
Mikhail Efimov
48b7d75aaf
[3.14] gh-140936: Fix JIT assertion crash at finalization if some generator is alive (GH-140969) (GH-141494)
gh-140936: Fix JIT assertion crash at finalization if some generator is alive (GH-140969)
2025-11-13 16:11:57 +00:00
Miss Islington (bot)
9f42519431
[3.14] GH-141212: Fix possible memory leak in gc_mark_span_push (gh-141213) (gh-141364)
(cherry picked from commit f835552946)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
2025-11-10 16:55:01 +00:00
Miss Islington (bot)
d7aace78e9
[3.14] gh-140530: fix a reference leak in an error path for raise exc from cause (GH-140908) (#141282)
gh-140530: fix a reference leak in an error path for `raise exc from cause` (GH-140908)

Fix a reference leak in `raise E from T` when `T` is an exception
subtype for which `T.__new__` does not return an exception instance.
(cherry picked from commit 0c77e7c23b)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-09 17:04:26 +01:00
Victor Stinner
36e9f672f2
[3.14] Fix compiler warnings in remote debugging (#141060) (#141067)
Fix compiler warnings in remote debugging (#141060)

Example of fixed warnings on 32-bit Windows:

    Python\remote_debugging.c(24,53): warning C4244: 'function':
    conversion from 'uint64_t' to 'uintptr_t', possible loss of data

    Modules\_remote_debugging_module.c(789,44): warning C4244:
    'function': conversion from 'uint64_t' to 'size_t', possible loss
    of data

(cherry picked from commit f458ac01ba)
2025-11-05 19:49:39 +00:00
Chris Eibl
f0eb7d4c9a
[3.14] gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist (GH-140548) (#140923)
gh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but `preserve_none` and `musttail` do not exist. (GH-140548)


(cherry picked from commit 2f60b8f02f)

Co-authored-by: Krishna Chaitanya <141550576+XChaitanyaX@users.noreply.github.com>
2025-11-04 20:43:18 +00:00
Miss Islington (bot)
331b4b868c
[3.14] gh-140815: Fix faulthandler for invalid/freed frame (GH-140921) (#140981)
gh-140815: Fix faulthandler for invalid/freed frame (GH-140921)

faulthandler now detects if a frame or a code object is invalid or
freed.

Add helper functions:

* _PyCode_SafeAddr2Line()
* _PyFrame_SafeGetCode()
* _PyFrame_SafeGetLasti()

_PyMem_IsPtrFreed() now detects pointers in [-0xff, 0xff] range
as freed.
(cherry picked from commit a84181c31b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-04 11:18:23 +00:00
Ken Jin
4d68b758fa
[3.14] gh-140104: Revert "Set next_instr properly in the JIT during exceptions (GH-140233) (GH-140687)" (#140890)
Revert "[3.14] gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233) (GH-140687)"

This reverts commit 2e21672803.
2025-11-01 18:41:01 +00:00
Miss Islington (bot)
a7cfe862ba
[3.14] gh-131927: Do not emit PEP 765 warnings in ast.parse() (GH-139642) (GH-140786)
ast.parse() no longer emits syntax warnings for
return/break/continue in finally (see PEP-765) -- they are only
emitted during compilation.
(cherry picked from commit ad0a3f733b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-30 11:25:34 +00:00
Mikhail Efimov
2e21672803
[3.14] gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233) (GH-140687)
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-10-27 23:49:10 +00:00
Miss Islington (bot)
c1bfd4cb9c
[3.14] gh-140358: Bring back elapsed time and unreachable count to gc debug output (GH-140359) (#140405)
Co-authored-by: Pål Grønås Drange <paal.drange+pgdr@gmail.com>
2025-10-27 15:29:43 +02:00
Miss Islington (bot)
11b5e0b9c2
[3.14] gh-140517: fix leak in map_next in strict mode (GH-140543) (#140554)
gh-140517: fix leak in `map_next` in strict mode (GH-140543)
(cherry picked from commit be5af997f3)

Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-10-24 22:00:36 +05:30
Miss Islington (bot)
8285bc7ea2
[3.14] gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (GH-140506) (#140509)
gh-140471: Fix buffer overflow in AST node initialization with malformed `_fields` (GH-140506)
(cherry picked from commit 95953b692d)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-23 10:20:21 -07:00
Mark Shannon
d1a434f7b2
[3.14] GH-139951: Fix major GC performance regression. Backport of GH-140262 (GH-140447)
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead
* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
2025-10-23 15:26:58 +01:00
Miss Islington (bot)
d7fe4e99a2
[3.14] gh-140301: Fix memory leak in subinterpreter PyConfig cleanup (GH-140303) (#140360)
gh-140301: Fix memory leak in subinterpreter `PyConfig` cleanup (GH-140303)
(cherry picked from commit a615fb49c9)

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-20 09:54:41 +00:00
Miss Islington (bot)
6cee144d3a
[3.14] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) (GH-140338)
(cherry picked from commit f9323213c9)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-19 19:53:36 +00:00
Kumar Aditya
1d11627ba5
[3.14] gh-140067: Fix memory leak in sub-interpreter creation (GH-140111) (#140118)
* [3.14] gh-140067: Fix memory leak in sub-interpreter creation  (GH-140111)

Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally.
(cherry picked from commit 59547a251f)

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-18 19:40:43 +05:30
Miss Islington (bot)
3ca7ea1f8f
[3.14] gh-140257: fix data race on eval_breaker during finalization (GH-140265) (#140294)
gh-140257: fix data race on eval_breaker during finalization (GH-140265)
(cherry picked from commit c8729c9909)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-18 11:28:53 +00:00
Miss Islington (bot)
045e34964a
[3.14] gh-140061: Use _PyObject_IsUniquelyReferenced() to check if objects are uniquely referenced (gh-140062) (gh-140157)
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
(cherry picked from commit 32c264982e)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
2025-10-15 14:49:17 +00:00
Miss Islington (bot)
af28efd8b4
[3.14] gh-139640: Fix swallowing syntax warnings in different modules (GH-139755) (GH-140117)
Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.

Fix duplicated warnings in the "finally" block.

(cherry picked from commit 279db6bede)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* Update 2025-10-06-10-03-37.gh-issue-139640.gY5oTb.rst

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-14 15:56:01 +00:00
Kumar Aditya
90cd009209
[3.14] gh-139748: fix leaks in AC error paths when using unicode FS-b… (#139789)
* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-08 22:16:21 +05:30
Dino Viehland
81dc8b12f0
[3.14] gh-139525: Don't specialize functions which have a modified vectorcall (GH-139524) (#139709)
Don't specialize functions which have a modified vectorcall
2025-10-08 09:13:34 -07:00
Serhiy Storchaka
9ec4e3838a
[3.14] gh-138264: Fix gcc 14 compiler warnings (GH-138265) (GH-138426)
(cherry picked from commit 4a33077fdb)
2025-10-07 22:26:05 +02:00
Miss Islington (bot)
ac147be05f
[3.14] gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441) (#137519)
gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441)

Switch from `_testcapi` to `_testinternalcapi`.
(cherry picked from commit 7ab68cd506)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-10-07 20:47:26 +02:00