Commit graph

6019 commits

Author SHA1 Message Date
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)
b868f1414c
[3.14] gh-142534: Avoid TSan warnings in dictobject.c (gh-142544) (gh-142603)
There are places we use "relaxed" loads where C11 requires "consume" or
stronger. Unfortunately, compilers don't really implement "consume" so
fake it for our use in a way that avoids upsetting TSan.
(cherry picked from commit 0a62f8277e)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-12-11 21:51:02 +00:00
Petr Viktorin
e09c4deb25
[3.14] gh-123241: Don't modify ref count during visitation (GH-142232) (#142567)
(cherry picked from commit da8199f884)

Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2025-12-11 10:51:11 -08:00
Miss Islington (bot)
04ecff52c3
[3.14] gh-140222: Increase stack margin on debug build (GH-142452) (#142471)
gh-140222: Increase stack margin on debug build (GH-142452)

Increase _PyOS_MIN_STACK_SIZE if Python is built in debug mode.
(cherry picked from commit 49207a5226)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-09 15:59:42 +00:00
Miss Islington (bot)
43f696d942
[3.14] gh-142342: Fix m68k assembler operand constraints for %fpcr access (gh-142343) (#142458)
On m68k, an fmove instruction accessing %fpcr may only move from
or to a data register or a memory operand. The constraint "g" also
permits the use of address registers, which is invalid. The correct
constraint is "dm". Beginning with GCC 15, the register allocator
picks an address register in the code which causes SIGILL during
runtime.
(cherry picked from commit 02c085d48b)

Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Co-authored-by: Michael Karcher <github@mkarcher.dialup.fu-berlin.de>
2025-12-09 14:13:31 +00:00
Sam Gross
378b24b54e
[3.14] gh-133932: Tagged ints are heap-safe (free threading) (gh-142431)
The previous fix (gh-134494) didn't fix the free threading build.
2025-12-08 18:16:28 -05:00
Hugo van Kemenade
160ca1c8c3 Post 3.14.2 2025-12-05 21:59:38 +02:00
Hugo van Kemenade
df793163d5 Python 3.14.2 2025-12-05 18:49:16 +02:00
Hugo van Kemenade
206f1966ec Post 3.14.1 2025-12-02 18:16:07 +02:00
Hugo van Kemenade
57e0d177c2 Python 3.14.1 2025-12-02 14:51: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)
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
Miss Islington (bot)
f47e928574
[3.14] gh-116738: Fix thread-safety issue in re module for free threading (gh-141923) (gh-141990)
Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent
race conditions on the `executing` flag in free-threaded builds. Also added
tests for concurrent usage of the `re` module.

Without the atomic operations, `test_scanner_concurrent_access()` triggers
`assert(self->executing)` failures, or a thread sanitizer run emits errors.
(cherry picked from commit bc9e63dd9d)

Co-authored-by: Alper <alperyoney@fb.com>
2025-11-26 21:08:39 +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
Miss Islington (bot)
cabaa47668
[3.14] gh-116749: Fix code comment for _PyConfig_GIL_DEFAULT (gh-141804) (gh-141911)
(cherry picked from commit c490ffb7ac)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-11-24 16:10:59 +00: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)
cf141ab1b8
[3.14] fix memory order of _Py_atomic_store_uint_release (GH-141562) (GH-141663)
(cherry picked from commit 7800b78067)

Co-authored-by: SubbaraoGarlapati <53627478+SubbaraoGarlapati@users.noreply.github.com>
2025-11-17 14:38:00 +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
Bénédikt Tran
bf2865f80f
[3.14] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) (#139359)
* [3.14] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234)

Expose the XML Expat 2.7.2 mitigation APIs to disallow use of
disproportional amounts of dynamic memory from within an Expat
parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetAllocTrackerActivationThreshold(threshold)`, and
- `parser.SetAllocTrackerMaximumAmplification(max_factor)`.

(cherry picked from commit f04bea44c3)
(cherry picked from commit 68a1778b77)
2025-11-02 09:33:36 +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
Miss Islington (bot)
ce1deb947e
[3.14] gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636) (#140668)
gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636)

Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE have already been
fixed by commit 9258f3da91 (issue gh-134989).
(cherry picked from commit c636477523)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-27 14:15:49 +01: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
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)
95c03d018d
[3.14] gh-140153: Fix Py_REFCNT() definition on limited C API 3.11-3.13 (GH-140158) (#140164)
gh-140153: Fix Py_REFCNT() definition on limited C API 3.11-3.13 (GH-140158)
(cherry picked from commit 728d239e57)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-15 15:02:03 +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
511078099a
[3.14] gh-125996: fix thread safety of collections.OrderedDict (GH-133734) (#140053)
(cherry picked from commit 6481539a6d)
2025-10-13 23:25:24 +05:30
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)
75de39ba1b
[3.14] gh-137185: Fix _Py_DumpStack() async signal safety (gh-137187) (gh-137206)
Call backtrace() once when installing the signal handler to ensure that
libgcc is dynamically loaded outside the signal handler.

This fixes a "signal-unsafe call inside of a signal" TSan error from
test_faulthandler.test_enable_fd.
(cherry picked from commit 11a8652e25)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-10-07 18:11:46 +00:00
Miss Islington (bot)
bfcd5f25a5
[3.14] gh-138661: fix data race in PyCode_Addr2Line (GH-138664) (#138834)
gh-138661: fix data race in `PyCode_Addr2Line` (GH-138664)
(cherry picked from commit ea26f6da39)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-07 18:06:45 +00:00
Miss Islington (bot)
e3d102ecdc
[3.14] gh-136823: Update documentation on excluded headers in Python.h (GH-136824) (#137437)
gh-136823: Update documentation on excluded headers in Python.h (GH-136824)
(cherry picked from commit c2428ca9ea)

Co-authored-by: Sina Zel taat <111974143+SZeltaat@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-10-07 23:23:33 +05:30
Sam Gross
fb699effbf
[3.14] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518) (gh-137730)
There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
(cherry picked from commit a10152f8fd)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-07 13:45:23 -04:00
Victor Stinner
6ed9be1a55
[3.14] gh-137058: Sync _Py_NULL macro with the main branch (#137409)
gh-137058: Sync _Py_NULL macro with the main branch

* use __STDC_VERSION__ >= 202311L instead of
  __STDC_VERSION__ > 201710L.
* Check for _MSC_VER.
2025-10-07 18:41:45 +02:00
Hugo van Kemenade
4319884256 Post 3.14.0 2025-10-07 17:15:20 +03:00
Hugo van Kemenade
ebf955df7a Python 3.14.0 2025-10-07 12:34:52 +03:00
Hugo van Kemenade
869f1d8f6a Post 3.14.0rc3 2025-09-18 12:49:45 +01:00
Hugo van Kemenade
1c5b28405a Python 3.14.0rc3 2025-09-18 09:45:38 +01:00
Miss Islington (bot)
0e4e608f03
[3.14] gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (GH-137470) (#139039)
gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (GH-137470)

With https://github.com/llvm/llvm-project/pull/150201 being merged, there is
now a better way to generate the Emscripten trampoline, instead of including
hand-generated binary WASM content. Requires Emscripten 4.0.12.
(cherry picked from commit 2629ee4eb0)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-09-17 17:21:01 +01:00
Miss Islington (bot)
c0d490d9c4
[3.14] gh-135755: Make Py_MAX_SCRIPT_PATH_SIZE private (GH-138350) (#138356)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-16 15:49:35 +03:00
Victor Stinner
3643a26a01
[3.14] gh-138349: Fix crash when combining module-level annotation and listcomp (#138363) (#138749)
* gh-138349: Fix crash when combining module-level annotation and listcomp (#138363)

(cherry picked from commit 7a6fd4a45d)

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-09-11 08:43:57 +03:00
Peter Bierma
8b3f9ae2ca
[3.14] gh-137883: Check the recursion limit for specialized keyword argument calls (GH-137887) (#137945)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-08-25 19:19:39 +03:00
Hugo van Kemenade
5322260352 Post 3.14.0rc2 2025-08-14 19:10:50 +03:00
Hugo van Kemenade
31967d8de3 Python 3.14.0rc2 2025-08-14 15:19:47 +03:00
Petr Viktorin
946b226b90
[3.14] gh-137288: Update version in magic number log (GH-137665) (#137667)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-12 12:18:20 +00:00
Irit Katriel
0ccf244a19
[3.14] gh-137288: Fix bug where boolean expressions are not associated with the correct exception handler (GH-137310). (#137427)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-08-12 12:56:37 +03:00
Hugo van Kemenade
9f25781bf9 Post 3.14.0rc1 2025-07-22 21:54:14 +03:00
Hugo van Kemenade
48f8831004 Python 3.14.0rc1 2025-07-22 19:42:44 +03:00
Hugo van Kemenade
8e43b130f7
[3.14] gh-134009: Expose PyMutex_IsLocked in the public C API (gh-134365) (#136971)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-07-22 12:48:08 +03:00
Miss Islington (bot)
11f510167c
[3.14] gh-133296: Publicly expose critical section API that accepts PyMutex (gh-135899) (#136969)
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-07-22 12:44:59 +03:00