Commit Graph
10002 Commits
Author SHA1 Message Date
Miss Islington (bot)andIrit Katriel 4500eed792 [3.14] gh-156466: fix cleanup on error in codegen_function_body (GH-156511) (#156579)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-10-25 16:01:30 +02:00
Jelle Zijlstra 72caed7b1f [3.14] gh-159739: Hold the codec registry lock while unregistering (GH-160168) (#160485)
Concurrent calls to codecs.unregister() can shrink the search path between its length check and indexed lookup in a free-threaded build. The lookup then returns NULL and an unconditional decref crashes the interpreter; hold the registry mutex across the scan and removal. Also reported in gh-157078. Backport to 3.15 and 3.14.
(cherry picked from commit 784b305df8)
2026-10-24 13:43:43 -07:00
Pablo Galindo SalgadoandZanie Blue 1fa5e07274 [3.14] gh-128883: Store ELF perf trampoline templates in read-only data (GH-160366) (#160492)
CPython copies the trampoline templates into executable memory. Keep the
ELF source in .rodata so BOLT preserves its bytes and boundaries.
(cherry picked from commit 1ff83ad7ad)

Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-10-23 20:56:21 +00:00
Carl Meyer 9eab48adf8 [3.14] gh-160299: Preserve references from inlined comprehensions (GH-160413) (#160457)
Adapt the reference-flag propagation from GH-156819 to fix gh-160299 without backporting the comprehensive changes to comprehension scope representation and compilation.

(cherry picked from commit cc3a0c9d3a)
2026-10-23 18:31:06 +00:00
Miss Islington (bot)andIrit Katriel a53b1324fc [3.14] gh-156459: Fix cleanup on error in compiler_set_qualname (GH-156462) (#156575)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-10-23 20:35:42 +03:00
Miss Islington (bot)andJelle Zijlstra a99e9298b9 [3.14] gh-159739: Preserve ContextVar cache updates from finalizers (GH-160197) (#160329)
Resetting a ContextVar can finalize the replaced value, whose finalizer may set the variable again. Updating the lookup cache after releasing the old context root overwrites that newer cached value, so get() can return a stale value or use a freed object. Update the cache before the old root can be released. Backport to 3.15 and 3.14.
(cherry picked from commit f4f8b933e3)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
2026-10-22 15:22:13 -07:00
Miss Islington (bot)andJelle Zijlstra ddf7156bab [3.14] gh-159739: Skip context watchers cleared during notification (GH-160164) (#160289)
A context watcher callback can clear a later watcher while a context-switch notification is being dispatched. The dispatcher still uses its earlier snapshot of active watchers, so it calls a NULL callback and crashes; check that each callback is still registered before invoking it. Backport to 3.15 and 3.14.
(cherry picked from commit 0a5762621f)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
2026-10-22 15:20:56 -07:00
Donghee Na 1bcc0d165a [3.14] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160183) 2026-10-22 09:54:37 -07:00
Jelle Zijlstra a03d287388 [3.14] gh-159739: Fix reference and error handling in warnings (GH-159758) (#160085)
Do not release the borrowed skip_file_prefixes argument, and stop if
allocation of the fallback filename fails.

(cherry picked from commit fab1405da8)
2026-10-21 19:24:15 +00:00
Miss Islington (bot)andJelle Zijlstra b93dabc62d [3.14] gh-159739: Clear free-threaded GC worklists after early errors (GH-159979) (#160017)
(cherry picked from commit 2315d94664)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
2026-10-21 11:49:19 -07:00
d8d3df5336 [3.14] gh-149816: #96 Fix a race condition in invoke_gc_callback with free threading (GH-150029) (GH-156119) (#159310)
(cherry picked from commit 91d71dd670)
(cherry picked from commit e96bd136eb)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Co-authored-by: dzaramelcone <134235821+dzaramelcone@users.noreply.github.com>
2026-10-20 17:42:26 -07:00
442d6ad7cd [3.14] gh-159739: Bound encoding-name lookahead in surrogatepass (GH-159785) (#159912)
(cherry picked from commit 905aab60f7)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-10-20 18:38:32 +00:00
3ef1c8165c [3.14] gh-159739: Avoid leaking references during free-threaded GC enumeration (GH-159781) (#159908)
(cherry picked from commit 7652a6dacc)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-10-20 11:15:00 -07:00
Miss Islington (bot)andJelle Zijlstra 62603cd971 [3.14] gh-159739: Handle interpreter configuration encoding errors (GH-159747) (#159844)
Propagate UTF-8 conversion errors before copying a string configuration
value.
(cherry picked from commit 626394e0a3)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
2026-10-20 11:12:29 -07:00
Miss Islington (bot)andJelle Zijlstra bae32d612d [3.14] gh-159739: Check character formatting allocation failure (GH-159746) (#159840)
Propagate the error from PyUnicode_FromOrdinal() before using the
result.
(cherry picked from commit 5b0ab21364)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
2026-10-20 08:45:25 -07:00
a3fdda2a53 [3.14] gh-159739: Release replaced PyInitConfig strings (GH-159769) (#159810)
gh-159739: Release replaced PyInitConfig strings (GH-159769)

* gh-159739: Release replaced PyInitConfig strings

Backport to 3.15 and 3.14.

---------
(cherry picked from commit 395d766d4f)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-10-20 00:32:57 +00:00
Neil SchemenauerandNathan Goldbaum 84990b5b80 [3.14] gh-158973: Reset the warnings lock after fork in the child (gh-158974) (gh-159615)
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2026-10-20 00:06:42 +00:00
Tian Gaoandlimadog9 a436cd2191 [3.14] gh-158121: Preserve instruction events when line monitoring is… (#159741)
* [3.14] gh-158121: Preserve instruction events when line monitoring is disabled (GH-158456)
(cherry picked from commit f0f76de0c8)

Co-authored-by: limadog9 <jakewallin42@gmail.com>
2026-10-19 14:19:52 -07:00
Kumar AdityaandNathan Goldbaum c542ecdec8 [3.14] gh-159041: Fix use-after-free in asyncio task tracking during thread state cleanup (#159073) (#159695)
(cherry picked from commit 999855b07f)

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2026-10-19 06:39:35 +00:00
Miss Islington (bot)andPengyu Lee b643e2f531 [3.14] gh-157906: fix an incorrect architecture macro check in free-threaded GC (gh-157907) (gh-159426)
Fix typo in free-threaded GC prefetch check for 32-bit x86 MSVC.
(cherry picked from commit 1b015e66f0)

Co-authored-by: Pengyu Lee <lipengyu@kylinos.cn>
2026-10-16 20:10:09 -07:00
Victor StinnerandNathan Goldbaum 7c04882496 [3.14] gh-157415: Fix data race in pthread wrapper (#157430) (#159547)
Use free() instead of PyMem_RawFree() in pythread_wrapper() to avoid
a data race if another thread calls PyMem_SetAllocator() in parallel.

(cherry picked from commit d1878ccb44)

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2026-10-16 15:55:12 +00:00
a11d4cd273 [3.14] gh-159320: Enable stack size detection on Android (GH-159321) (#159410)
gh-159320: Enable stack size detection on Android (GH-159321)

Extend the use of pthread_getattr_np in stack size detection from any glibc linux to any glibc *or* android linux. Update tests for android's new recursion limit.
(cherry picked from commit 8ff41c2ae7)

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2026-10-14 12:44:00 +00:00
4489dc3e16 [3.14] gh-156909: Fix AST.__repr__ call getting the _fields attribute (GH-157490) (GH-157596) (GH-159232)
(cherry picked from commit ad0a18a17d)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-10-13 12:12:05 +02:00
Gregory P. Smith 758278c2eb [3.14] gh-159184: Do not compare set elements when marshalling a set (GH-159196) (#159206)
Set elements are written in the order of their dumps.  They were sorted
as (dump, element) pairs, so elements with the same dump were compared.
That failed for a set of several complex NaNs, which the compiler can
produce by constant folding, making the module impossible to marshal.
On this branch the failure was reported as MemoryError.

Sort (dump, index, element) tuples, in which the indexes are all
different.  Elements with the same dump stay in the order of the set,
as float NaNs did before.

(cherry picked from commit 1967a87ad3)
2026-10-11 23:27:34 +00:00
Gregory P. Smith 09e1e663c9 [3.14] gh-159185: Fix marshalling of a set modified while its elements are marshalled (GH-159195) (#159200)
Marshalling a set element can run Python code (__buffer__, an audit
hook) which changes the set.  The number of elements was read before
the loop, so a set which grew was written past the end of the list and
one which shrank left NULL items in the list which was then sorted.
Raise RuntimeError("set changed size during iteration") instead.

(cherry picked from commit cd71799c47)
2026-10-11 14:52:10 -07:00
Victor Stinner b23d657d0c [3.14] gh-158893: Make os.strerror() thread-safe (#159120) (#159145)
[3.15] gh-158893: Make os.strerror() thread-safe (#159120)

* gh-157695: Parse also _Py_HAVE_xxx variables in sysconfig (#158926)

Add parse_config_h() tests to test_sysconfig.

(cherry picked from commit 978a8befa5)

* gh-158893: Make os.strerror() thread-safe (#158927)

Make os.strerror() thread-safe: use the reentrant strerror_r()
function if available.

* The configure script now checks if strerror_r() is supported.
* Add a stress test to test_free_threading.test_os (new module).
* Add a comment on decode_current_locale() assertion which fails if
  the input string is mutated.
* Add an assertion to _Py_DecodeLocale() to detect if the input
  string was mutated during the function call.

* gh-158893: Add internal _Py_strerror() function (#158982)

Add a new internal _Py_strerror() function to Python/fileutils.c. It
uses strerror_r() if available, or use strerror() otherwise.

Replace all strerror(code) calls with _Py_strerror(code).

(cherry picked from commit 15dd7356f3)
(cherry picked from commit c774d1526f)
2026-10-10 20:54:38 +00:00
Maurycy Pawłowski-Wieroński fb313a3948 [3.14] gh-158539: Fix macOS runtime section lookup for remote debugging (GH-158874) (#158906) 2026-10-06 17:13:01 +01:00
Miss Islington (bot)andPeter Hawkins 18ef0f0cb5 [3.14] gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading (gh-153720) (#158904)
gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading (gh-153720)

Under high thread concurrency in free-threaded builds, `_Py_Specialize_LoadGlobal` suffers from lock contention when acquiring the critical section mutexes for the `globals` and `builtins` dictionaries during bytecode specialization.

This PR skips LOAD_GLOBAL bytecode specialization if acquiring the two object mutexes would block.
(cherry picked from commit ac8ba0ca5a)

Co-authored-by: Peter Hawkins <phawkins@google.com>
2026-10-06 18:47:51 +05:30
e0c28e2a00 [3.14] Add MSan to CI (GH-158625) (#158834)
* Run a job that the test suite with MSan to the CI (#158625)

* Run the test suite with MSan in CI

* Additional fixes

* Add `_Py_MSAN_UNPOISON_STRING`

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

---------

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
(cherry picked from commit b93fb19a6e)

* Mark bytes returned by getrandom as initialized for MSan

* Handle invalid non-ASCII struct formats in the fuzz harness

---------

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
2026-10-05 10:24:22 +00:00
Pablo Galindo SalgadoandMaurycy Pawłowski-Wieroński 4753622ec0 [3.14] gh-154194: Degrade frames instead of failing the sample (GH-154195) (#158833)
* gh-154194: Degrade unreadable frames on 3.14

(cherry picked from commit 7d25916b41)

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>

* Preserve the stable ABI when creating fallback frame names

---------

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-10-05 10:04:44 +00:00
Miss Islington (bot)andBhuvansh a9eeb9f2f5 [3.14] gh-156204: Guard recursion in PyErr_GivenExceptionMatches (GH-156205) (GH-158623)
(cherry picked from commit 20d5e67fc5)

Co-authored-by: Bhuvansh <bhuvanshkataria@gmail.com>
2026-10-02 20:50:00 +00:00
Miss Islington (bot)andGregory P. Smith 4443885c49 [3.14] gh-158446: Reject float format precision near INT_MAX (GH-158474) (#158477)
gh-158446: Reject float format precision near INT_MAX (GH-158474)

Formatting a float or complex with a precision within about 1000 of
INT_MAX could crash or produce incorrect output.
PyOS_double_to_string() now raises ValueError("precision too big") for
such precisions, as the format string parsers already do for
precisions above INT_MAX.

The limit applies regardless of presentation type or value, so a few
calls that previously succeeded (inf, nan, or 'g' with such a
precision) now raise as well.
(cherry picked from commit b7b4f3ecf2)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-09-30 08:36:53 +00:00
Miss Islington (bot)andHimesh Rupchandani b42e5bad03 [3.14] gh-158364: Don't report other interpreters' threads in sys._current_frames (GH-158369) (GH-158472)
(cherry picked from commit c3cb46870b)

Co-authored-by: Himesh Rupchandani <rupchandanihimesh69@gmail.com>
2026-09-30 02:53:39 +00:00
Kumar Aditya 6daaf3b2a6 [3.14] gh-157838: Merge biased refcounts on behalf of detached threads (#157839) (#158012) 2026-09-29 08:22:24 +05:30
Miss Islington (bot)andノウラ | Flare 373bc1abdf [3.14] gh-157549: Use sysconf() for the page size in remote_debug.h (GH-157800) (#157814)
gh-157549: Use sysconf() for the page size in remote_debug.h (GH-157800)

getpagesize() is not an ISO C or POSIX function. Darwin hides the prototype under -std=c11, so the _remote_debugging build fails with -Werror=implicit-function-declaration. That is the failure in the reported x86_64-apple-darwin → arm64-apple-darwin cross build.

Call sysconf(_SC_PAGESIZE) instead, which is already how resource.getpagesize() works. Fall back to 4096 if sysconf() fails.

--without-remote-debug is unchanged. That flag only disables the target-side attach protocol (Py_REMOTE_DEBUG); it does not exclude the _remote_debugging client module.
(cherry picked from commit 9193375382)

Co-authored-by: ノウラ | Flare <nouraellm@gmail.com>
2026-09-19 16:45:19 +00:00
Pablo Galindo Salgado d3369c2f67 [3.14] gh-156114: Fix crash in perf trampoline with unencodable code names (GH-156300) (#157775) 2026-09-18 21:35:08 +00:00
Miss Islington (bot)andVictor Stinner c348765d48 [3.14] gh-128509: Use bytes singletons in marshal (GH-157398) (#157432)
gh-128509: Use bytes singletons in marshal (GH-157398)

Replace soft deprecated PyBytes_FromStringAndSize(NULL, n) with
PyBytes_FromStringAndSize(str, n) so marshal can get bytes singleton.
(cherry picked from commit 658612ae77)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-13 14:45:28 +00:00
Miss Islington (bot)andAbdul Mohammad 0ba71429fa [3.14] gh-155504: Set the interpreter before fallible thread state initialization (GH-155590) (#155885)
gh-155504: Set the interpreter before fallible thread state initialization (GH-155590)
(cherry picked from commit 94a75f74a1)

Co-authored-by: Abdul Mohammad <154353563+abdulm5@users.noreply.github.com>
2026-09-08 13:48:13 +05:30
Miss Islington (bot) dd36d014da [3.14] gh-156091: Fix crash compiling deeply nested inlined comprehensions (GH-156957) (#156993) 2026-09-05 16:27:05 +00:00
Miss Islington (bot)andStan Ulbrych 1546d44f6e [3.14] gh-156689: Fix out-of-bounds read in PyAst_CheckMode() for mode='func_type' (GH-156697) (#156704)
(cherry picked from commit d7f9c6400f)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-31 14:19:57 +01:00
Irit Katriel 3656c15ce8 [3.14]gh-156466: fix cleanup on error after Enter in codegen_enter_scope (#156467) (#156617)
gh-156466: fix cleanup on error after Enter in codegen_enter_scope (#156467)

(cherry picked from commit 41b3f0af26)
2026-08-30 14:14:31 +01:00
Irit Katriel e9eb34f390 [3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope (#156522)
[3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope
2026-08-30 14:13:40 +01:00
Miss Islington (bot)andSerhiy Storchaka d4ae98b0ec [3.14] gh-86427: Use the console code page for the stdio encoding on Windows (GH-155415) (GH-156603)
In the legacy Windows stdio mode PyConfig.stdio_encoding is now initialized
with the console output code page instead of the ANSI code page.

Only one encoding can be specified, so sys.stdin.encoding is still wrong if
the input code page differs from the output one.
(cherry picked from commit 0bb312a4ea)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-08-29 19:45:46 +00:00
Serhiy Storchaka 7755fce76f [3.14] gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410) (GH-156596)
It was hard coded to map file descriptors 0, 1 and 2 to the console code
page, but a console can be opened as any file descriptor, and other
character devices, like NUL, are not consoles.

The file handle is now queried.  The UTF-8 code page is also now reported
as "utf-8" instead of "cp65001".

(cherry picked from commit b4aea41d1c)
2026-08-29 18:50:41 +00:00
Miss Islington (bot)andJelle Zijlstra bf85294394 [3.14] gh-156466: Fix additional compiler scope cleanup errors (GH-156547) (#156572)
gh-156466: Fix additional compiler scope cleanup errors (GH-156547)
(cherry picked from commit f4874f381c)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-08-29 12:42:26 +00:00
Miss Islington (bot)andIrit Katriel 4c949e3946 [3.14] gh-156525: fix a few error path scope management bugs in symtable (GH-156526) (#156533)
gh-156525: fix a few error path scope management bugs in symtable (GH-156526)
(cherry picked from commit 932822cbc9)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 19:56:34 -07:00
Miss Islington (bot)andIrit Katriel 28b944cc03 [3.14] gh-156466: fix cleanup on error in codegen_class_body (GH-156507) (#156536)
gh-156466: fix cleanup on error in codegen_class_body (GH-156507)
(cherry picked from commit 683ef4082d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 21:35:29 +00:00
Miss Islington (bot) 56cc48239d [3.14] gh-156395: Report frozen objects on free-threaded GC build (GH-156396) (#156421)
gh-156395: Report frozen objects on free-threaded GC build (GH-156396)
2026-08-28 09:51:31 -07:00
Miss Islington (bot)andIrit Katriel 604ab79330 [3.14] gh-156466: fix cleanup on error in codegen_function_annotations (GH-156502) (#156509)
gh-156466: fix cleanup on error in codegen_function_annotations (GH-156502)
(cherry picked from commit 0e29768493)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 14:42:53 +00:00
Irit Katriel e93fe16a08 [3.14] gh-156466: fix cleanup on error in codegen_setup_annotations_scope (#156473) (#156499)
gh-156466: fix cleanup on error in codegen_setup_annotations_scope (#156473)

(cherry picked from commit 24e5a55ccb)
2026-08-28 10:42:36 +01:00