Commit graph

15186 commits

Author SHA1 Message Date
Miss Islington (bot)
7ff87fa8e1
[3.14] gh-143200: fix UAFs in Element.__{set,get}item__ when the element is concurrently mutated (GH-143226) (#143273)
gh-143200: fix UAFs in `Element.__{set,get}item__` when the element is concurrently mutated (GH-143226)
(cherry picked from commit b6b0e14b3d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-12-29 17:57:54 +00:00
Miss Islington (bot)
723ed8c507
[3.14] gh-143164: Fix incorrect error message for ctypes bitfield overflow (GH-143165) (GH-143176)
(cherry picked from commit b9a4806430)

Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
2025-12-25 17:34:02 +00:00
Miss Islington (bot)
88a4d0d34b
[3.14] gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131) (GH-143169)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item.
(cherry picked from commit 579c5b496b)

Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
2025-12-25 19:09:53 +02:00
Miss Islington (bot)
240ee20770
[3.14] gh-143004: Fix possible use-after-free in collections.Counter.update() (GH-143044) (GH-143166)
This happened when the Counter was mutated when incrementing
the value for an existing key.
(cherry picked from commit 86d904588e)

Co-authored-by: kaushal trivedi <155625932+Kaushalt2004@users.noreply.github.com>
2025-12-25 13:41:10 +02:00
Miss Islington (bot)
aee8c217bd
[3.14] gh-122431: Correct the non-negative error message in readline.append_history_file (GH-143075) (GH-143090)
gh-122431: Correct the non-negative error message in `readline.append_history_file` (GH-143075)

"positive" -> "non-negative", since zero is included.
(cherry picked from commit a273bc99d2)

Co-authored-by: Zheng Yu <dataisland@outlook.com>
2025-12-23 05:01:41 +00:00
Miss Islington (bot)
586047a8d8
[3.14] gh-143012: use Py_ssize_t cast for PyBytes_FromStringAndSize (GH-143013) (#143014)
gh-143012: use `Py_ssize_t` cast for `PyBytes_FromStringAndSize` (GH-143013)
(cherry picked from commit 5989095dfd)

Co-authored-by: AZero13 <gfunni234@gmail.com>
2025-12-20 08:02:44 +00:00
Miss Islington (bot)
8c92d665ee
[3.14] gh-112127: Fix possible use-after-free in atexit.unregister() (GH-114092) (#142878)
gh-112127: Fix possible use-after-free in atexit.unregister() (GH-114092)
(cherry picked from commit 2b466c47c3)

Co-authored-by: Benjamin Johnson <ben332004@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-12-17 21:36:12 +05:30
Miss Islington (bot)
897e2b46fb
[3.14] gh-142783: Fix possible use after free in zoneinfo module (GH-142790) (GH-142862)
(cherry picked from commit 8307a14d0e)

Co-authored-by: wangxiaolei <fatelei@gmail.com>
2025-12-17 09:23:59 +00:00
Miss Islington (bot)
d089cad656
[3.14] gh-142495: Make defaultdict keep existed value when racing with __missing__ (GH-142668) (GH-142832)
(cherry picked from commit a043407510)

Co-authored-by: Edward Xu <xuxiangad@gmail.com>
2025-12-16 15:31:05 +00:00
Miss Islington (bot)
c31ea74970
[3.14] gh-142595: Amend be5e0dcded (fix NULL pointer dereference) (GH-142775) (#142788)
gh-142595: Amend be5e0dcded (fix NULL pointer dereference) (GH-142775)
(cherry picked from commit 15a9762500)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-16 15:42:43 +05:30
Cody Maloney
58da2a9d94
[3.14] gh-142594: fix by property calls io.TextIOWrapper.detach (GH-142706) (GH-142755)
(cherry picked from commit 1d3854a19a)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
2025-12-16 10:55:25 +01:00
Miss Islington (bot)
575174ee78
[3.14] gh-142595: add type check for namedtuple call during decimal initialization (GH-142608) (GH-142623)
(cherry picked from commit be5e0dcded)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-15 15:03:57 +01: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
Sam Gross
12d2b95adf
[3.14] gh-142589: Fix PyUnstable_Object_IsUniqueReferencedTemporary (gh-142593) (#142597)
PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged
ints on the evaluation stack properly.
(cherry picked from commit a26c831bc4)
2025-12-11 20:08:45 +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)
fc40e7dc52
[3.14] Fix os.posix_spawn() error handling (GH-142532) (#142582)
Fix os.posix_spawn() error handling (GH-142532)

Consistently use `goto exit;` in `py_posix_spawn()`.
(cherry picked from commit 8cfa351560)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-12-11 17:32:11 +00:00
Miss Islington (bot)
7218be0199
[3.14] gh-142556: fix crash when a task gets re-registered during finalization in asyncio (GH-142565) (#142566)
gh-142556: fix crash when a task gets re-registered during finalization in `asyncio` (GH-142565)
(cherry picked from commit 42d2bedb87)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-12-11 10:00:44 +00:00
Miss Islington (bot)
94012d65c9
[3.14] gh-116738: Statically initialize special constants in cmath module (gh-142161) (gh-142261)
The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
(cherry picked from commit 2dac9e6016)

Co-authored-by: Alper <alperyoney@fb.com>
2025-12-04 14:51:55 +00:00
Miss Islington (bot)
212b096b2a
[3.14] gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690) (#141793)
Co-authored-by: Prithviraj Chaudhuri <p.chaudhuri1993@gmail.com>
2025-11-30 14:32:11 +02: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
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)
972aa93692
[3.14] gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802) (#141847)
gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802)

* gh-141801: Use accessors for ASN1_STRING fields

While ASN1_STRING is currently exposed, it is better to use the
accessors. See https://github.com/openssl/openssl/issues/29117 where, if
the type were opaque, OpenSSL's X509 objects could be much more
memory-efficient.

* Update Modules/_ssl.c



* Update Modules/_ssl.c



---------
(cherry picked from commit c41fce08a5)

Co-authored-by: David Benjamin <davidben@davidben.net>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 10:53:06 -08:00
Miss Islington (bot)
af586d8d26
[3.14] gh-116738: Make csv module thread-safe (gh-141365) (gh-141825)
Added a critical section to protect the states of `ReaderObj` and `WriterObj` in the free-threading build. Without the critical sections, both new free-threading tests were crashing.
(cherry picked from commit fb26d9c2ef)

Co-authored-by: Alper <alperyoney@fb.com>
2025-11-21 16:47:13 +00:00
Victor Stinner
5398d088f4
[3.14] gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796) (#141800)
gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796)

Include Python.h before system headers to make sure that
_remote_debugging_module.c uses the same types (ABI) than Python.

(cherry picked from commit 722f4bb8c9)
2025-11-20 18:13:03 +01:00
Miss Islington (bot)
7cb15f93fe
[3.14] gh-141659: Fix bad file descriptor error in subprocess on AIX (GH-141660) (GH-141738)
/proc/self does not exist on AIX.
(cherry picked from commit 92c5de73b8)

Co-authored-by: Ayappan Perumal <ayappap2@in.ibm.com>
2025-11-19 08:05:01 +00:00
Gregory P. Smith
0d8fb0b852
[3.14] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614)
This splits the OS API specific functionality to get the number of threads out
from the fallback Python method and warning raising code itself.  This way the
OS APIs can be queried before we've run
`os.register_at_fork(after_in_parent=...)` registered functions which
themselves may (re)start threads that would otherwise be detected.

This is best effort.  If the OS APIs are either unavailable or fail, the
warning generating code still falls back to looking at the Python threading
state after the CPython interpreter world has been restarted and the
after_in_parent calls have been made.  The common case for most Linux and macOS
environments should work today.

This also lines up with the existing TODO refactoring, we may choose to expose
this API to get the number of OS threads in the `os` module in the future.

Note: This is a simplified backport that maintains the void return type
for warn_about_fork_with_threads() and keeps PyErr_Clear() in the warning path,
as the error handling changes from fd8f42d3d1 are not needed in 3.14.
2025-11-16 19:45:29 +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
Miss Islington (bot)
79195df23c
[3.14] gh-140260: fix data race in _struct module initialization with subinterpreters (GH-140909) (#141501)
gh-140260: fix data race in `_struct` module initialization with subinterpreters (GH-140909)
(cherry picked from commit 63548b3699)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-11-13 17:23:22 +05:30
Miss Islington (bot)
0b44bc3379
[3.14] gh-124111: Fix TCL 9 thread detection (GH-141482)
(cherry picked from commit dc0987080e)

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2025-11-12 22:43:31 +00:00
Miss Islington (bot)
ba73decce1
[3.14] gh-132657: add regression test for PySet_Contains with unhashable type (GH-141411) (#141468)
gh-132657: add regression test for `PySet_Contains` with unhashable type (GH-141411)
(cherry picked from commit 2ac738d325)

Co-authored-by: M Bussonnier <bussonniermatthias@gmail.com>
2025-11-12 15:49:09 +00:00
Mohsin Mehmood
92c14a91d2
[3.14] gh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return (GH-141331) (GH-141453)
The assertion was checking wrong variable (skip_back vs skip_bytes).
(cherry picked from commit af80fac425)
2025-11-12 12:40:02 +02:00
Miss Islington (bot)
75b5157e84
[3.14] gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333) (GH-141457)
Fix error in assertion which causes failure if pos is equal to PY_SSIZE_T_MAX.
Fix undefined behavior in read() and readinto() if pos is larger that the size
of the underlying buffer.
(cherry picked from commit 7d54374f9c)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2025-11-12 10:23:26 +00:00
Miss Islington (bot)
d6b4f4b10f
[3.14] gh-100218: correctly set errno when socket.if_{nametoindex,indextoname} raise OSError (GH-140905) (#141284)
gh-100218: correctly set `errno` when `socket.if_{nametoindex,indextoname}` raise `OSError` (GH-140905)

Previously, socket.if_nametoindex() and socket.if_indextoname() could raise
an `OSError` with a `None` errno. Now, the errno from libc is propagated.
(cherry picked from commit 3ce2d57b2f)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-09 13:11:43 +00:00
Serhiy Storchaka
1a080199af
[3.14] gh-140615: Update docstrings in the fcntl module (GH-140619) (GH-141231)
* Refer to bytes objects or bytes-like objects instead of strings.
* Remove backticks -- they do not have effect on formatting.
* Re-wrap lines to ensure the pydoc output fits in 80 columns.
(cherry picked from commit 610377056b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-11-08 11:16:45 +00: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
Miss Islington (bot)
8675f55f6a
[3.14] Fix a compiler warning in _randommodule.c (GH-141058) (#141063)
Fix a compiler warning in _randommodule.c (GH-141058)

The test just before the cast ensures that the cast cannot overflow.

Fix the warning on 32-bit Windows:

    Modules\_randommodule.c(525,28): warning C4244: '=': conversion
    from 'uint64_t' to 'Py_ssize_t', possible loss of data
(cherry picked from commit 4ac16dd109)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-05 19:10:32 +00:00
Miss Islington (bot)
267af29832
[3.14] gh-140979: Fix off-by-one error in the RE code validator (GH-140984) (GH-141001)
It was too lenient and allowed MARK opcodes with too large value.
(cherry picked from commit 1326d2a808)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-11-04 18:16:51 +02: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
Cody Maloney
9a7dccd7a1
[3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611) (#140728)
* [3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611)

While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.
(cherry picked from commit 0f0a362768)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>

* fixup: Use older attribute name

---------

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-29 13:31:48 +01:00
Miss Islington (bot)
02604314ba
[3.14] GH-140590: Fix setstate for functools.partial C-module (GH-140671) (#140698)
GH-140590: Fix setstate for functools.partial C-module (GH-140671)

(cherry picked from commit d26686a7f8)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-10-28 18:15:27 +05:30
Miss Islington (bot)
84e01df175
[3.14] gh-134160: Add more comments for the xxlimited module (GH-140214) (GH-140664)
(cherry picked from commit 18e4a89e42)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-28 10:24:11 +01:00
Miss Islington (bot)
3bb0eb4ca9
[3.14] gh-140634: Fix a reference counting bug in os.sched_param.__reduce__() (GH-140667) (GH-140685)
(cherry picked from commit 364ae607d8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-10-27 20:08:57 +00:00
Sebastian Pipping
842c49b354
[3.14] gh-140593: Fix a memory leak in function my_ElementDeclHandler of pyexpat (GH-140602) (#140629)
[3.14] gh-140593: Fix a memory leak in function `my_ElementDeclHandler` of `pyexpat` (GH-140602)

Ensure that the memory allocated for the content model
passed to `my_ElementDeclHandler` is freed in all error
paths.

(cherry picked from commit e34a5e3304)
2025-10-26 15:19:18 +00:00
Miss Islington (bot)
96029bc472
[3.14] Remove unreachable break statements in _ctypes_test.c (GH-140585) (#140587)
Remove unreachable break statements in _ctypes_test.c (GH-140585)
(cherry picked from commit 2a1c9bd616)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-25 18:39:42 +03:00
Miss Islington (bot)
0fdae5f590
[3.14] gh-140474: Fix memory leak in array.array (GH-140478) (GH-140498)
gh-140474: Fix memory leak in `array.array` (GH-140478)
(cherry picked from commit aa9d0a61d5)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-23 10:20:16 +00:00
Miss Islington (bot)
01b52ea5c0
[3.14] gh-116738: Add critical section to dbm/gdbm context manager (gh-140391) (gh-140459)
(cherry picked from commit d51be28876)

Co-authored-by: Alper <alperyoney@fb.com>
2025-10-22 15:44:09 +00:00
Miss Islington (bot)
98d4c21c09
[3.14] gh-140398: fix memory leaks in readline module when PySys_Audit fails (GH-140400) (#140403)
gh-140398: fix memory leaks in `readline` module when `PySys_Audit` fails (GH-140400)
(cherry picked from commit e8e0f411ba)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-21 08:20:14 +00:00
Miss Islington (bot)
6493a6aaf3
[3.14] gh-140263: Fix data race in test_lock_two_threads (gh-140264) (gh-140369)
Clang-20 detects a data race between the unlock and the non-atomic
read of the lock state. Use a relaxed load for the assertion to avoid
the race.
(cherry picked from commit f11ec6e643)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-10-20 14:25:42 +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