Commit graph

15467 commits

Author SHA1 Message Date
AZero13
5989095dfd
gh-143012: use Py_ssize_t cast for PyBytes_FromStringAndSize (#143013) 2025-12-20 10:37:10 +03:00
Donghee Na
14f0b5191a
gh-142419: Add mmap.set_name method for user custom annotation (gh-142480) 2025-12-18 23:33:49 +09:00
Pablo Galindo Salgado
77b56eafde
gh-91048: Refactor common data into context object in Modules/_remote_debugging (#142879) 2025-12-17 17:43:52 +00:00
Petr Viktorin
7d81eab923
gh-142225: Add PyABIInfo_VAR to to _testcapimodule & _testinternalcapi (GH-142833) 2025-12-17 16:33:09 +01:00
Pablo Galindo Salgado
568a819f67
gh-138122: Validate base frame before caching in remote debugging frame cache (#142852) 2025-12-17 15:12:28 +00:00
Benjamin Johnson
2b466c47c3
gh-112127: Fix possible use-after-free in atexit.unregister() (GH-114092)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-12-17 17:09:57 +02:00
wangxiaolei
8307a14d0e
gh-142783: Fix possible use after free in zoneinfo module (GH-142790) 2025-12-17 08:35:08 +00:00
Edward Xu
a043407510
gh-142495: Make defaultdict keep existed value when racing with __missing__ (GH-142668) 2025-12-16 17:04:20 +02:00
Sergey B Kirpichev
15a9762500
gh-142595: Amend be5e0dcded (fix NULL pointer dereference) (GH-142775) 2025-12-16 10:52:20 +02:00
Alper
1a9cdaf63a
gh-116738: Make _bz2 module thread-safe (gh-142756)
Make the attributes in _bz2 module thread-safe on the free-threading build.
Attributes (eof, needs_input, unused_data) are now stored atomically or
accessed via mutex-protected getters.
2025-12-15 12:47:04 -05:00
yihong
1d3854a19a
gh-142594: fix by property calls io.TextIOWrapper.detach (GH-142706)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
2025-12-15 15:13:58 +01:00
Pablo Galindo Salgado
6658e2cb07
gh-138122: Add --subprocesses flag to profile child processes in tachyon (#142636) 2025-12-15 12:11:40 +00:00
Hugo van Kemenade
38ad651b67
gh-76007: Deprecate __version__ attribute in ctypes (#142679) 2025-12-15 13:30:23 +02:00
Kumar Aditya
fb554ad68d
gh-140414: streamline thread state access in asyncio (#142742) 2025-12-15 16:57:51 +05:30
Bénédikt Tran
d3ef5ba34d
gh-142451: correctly copy HMAC attributes in HMAC.copy() (#142510) 2025-12-14 09:45:36 +01:00
Alper
1eddef8193
gh-116738: Make zlib module thread-safe (gh-142432)
Makes the zlib module thread-safe free-threading build. Even though operations
are protected by locks, attributes exposed via PyMemberDef (eof, needs_input,
unused_data, unconsumed_tail) should still be stored atomically within locked
sections, since they can be read without acquiring the lock.
2025-12-12 13:14:42 -05:00
Sergey B Kirpichev
be5e0dcded
gh-142595: add type check for namedtuple call during decimal initialization (GH-142608) 2025-12-12 11:47:45 +01:00
Pablo Galindo Salgado
6a0135a392
gh-138122: Add exception profiling mode to the sampling profiler (#142561) 2025-12-11 20:46:34 +00:00
Neil Schemenauer
e38967ed60
gh-142531: Fix free-threaded GC performance regression (gh-142562)
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.
2025-12-11 12:30:56 -08:00
Sam Gross
a26c831bc4
gh-142589: Fix PyUnstable_Object_IsUniqueReferencedTemporary (gh-142593)
PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged
ints on the evaluation stack properly.
2025-12-11 14:41:03 -05:00
Bartosz Sławecki
8cfa351560
Fix os.posix_spawn() error handling (#142532)
Consistently use `goto exit;` in `py_posix_spawn()`.
2025-12-11 18:02:26 +01:00
AZero13
44d3dc6491
gh-142438: Added missing GIL release in _PySSL_keylog_callback when keylog_bio is unset (gh-142439) 2025-12-11 23:30:39 +09:00
Kumar Aditya
42d2bedb87
gh-142556: fix crash when a task gets re-registered during finalization in asyncio (#142565) 2025-12-11 15:04:49 +05:30
Dino Viehland
da8199f884
gh-123241: Don't modify ref count during visitation (GH-142232) 2025-12-11 09:54:29 +01:00
Pablo Galindo Salgado
5b19c75b47
gh-138122: Make the tachyon profiler opcode-aware (#142394) 2025-12-11 03:41:47 +00:00
AZero13
756e7d1f3b
Silence warning on conversion from uint64_t to uintptr_t in threads.c (#142437) 2025-12-09 10:18:51 +00:00
Sam Gross
80c2c2dfb5
gh-138122: Fix unused variable warning in threads.c (#142425) 2025-12-08 19:05:11 +00:00
Donghee Na
c4ccaf4b10
gh-141770: Annotate anonymous mmap usage if "-X dev" is used (gh-142079) 2025-12-08 14:47:19 +00:00
yihong
3db7bf2d18
gh-142207: remove assertions incompatible under profiling.sampling (#142331) 2025-12-08 04:45:04 +00:00
Pablo Galindo Salgado
d6d850df89
gh-138122: Don't sample partial frame chains (#141912) 2025-12-07 15:53:48 +00:00
Pablo Galindo Salgado
572c780aa8
gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137)
This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks.

When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process.

The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory.

The sampling profiler now enables frame caching by default.
2025-12-06 22:37:34 +00:00
Savannah Ostrowski
56a442d0d8
GH-141565: Add async code awareness to Tachyon (#141533)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-12-06 19:31:40 +00:00
Serhiy Storchaka
59f247e43b
gh-115952: Fix a potential virtual memory allocation denial of service in pickle (GH-119204)
Loading a small data which does not even involve arbitrary code execution
could consume arbitrary large amount of memory. There were three issues:

* PUT and LONG_BINPUT with large argument (the C implementation only).
  Since the memo is implemented in C as a continuous dynamic array, a single
  opcode can cause its resizing to arbitrary size. Now the sparsity of
  memo indices is limited.
* BINBYTES, BINBYTES8 and BYTEARRAY8 with large argument.  They allocated
  the bytes or bytearray object of the specified size before reading into
  it.  Now they read very large data by chunks.
* BINSTRING, BINUNICODE, LONG4, BINUNICODE8 and FRAME with large
  argument.  They read the whole data by calling the read() method of
  the underlying file object, which usually allocates the bytes object of
  the specified size before reading into it.  Now they read very large data
  by chunks.

Also add comprehensive benchmark suite to measure performance and memory
impact of chunked reading optimization in PR #119204.

Features:
- Normal mode: benchmarks legitimate pickles (time/memory metrics)
- Antagonistic mode: tests malicious pickles (DoS protection)
- Baseline comparison: side-by-side comparison of two Python builds
- Support for truncated data and sparse memo attack vectors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-12-05 19:17:01 +02:00
Sanyam Khurana
4238a975d7
gh-48752: Add readline.get_pre_input_hook() function (#141586)
Add readline.get_pre_input_hook() to retrieve the current pre-input
hook. This allows applications to save and restore the hook without
overwriting user settings.
2025-12-05 13:18:54 +01:00
Alper
2dac9e6016
gh-116738: Statically initialize special constants in cmath module (gh-142161)
The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
2025-12-04 09:21:51 -05:00
Alper
bc9e63dd9d
gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)
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.
2025-11-26 15:40:45 -05:00
Pablo Galindo Salgado
d07d3a3c57
gh-138122: Split Modules/_remote_debugging_module.c into multiple files (#141934)
gh-1381228: Split Modules/_remote_debugging_module.c into multiple files
2025-11-25 12:51:24 +00:00
Petr Viktorin
bf66bce4ee
gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-141785) 2025-11-24 13:26:35 +01:00
Brandt Bucher
227b9d326e
GH-140638: Add a GC "candidates" stat (GH-141814) 2025-11-22 21:59:14 +00:00
David Benjamin
c41fce08a5
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

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Modules/_ssl.c

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 09:17:45 -08:00
Chris Angelico
f21ed37daf
gh-141817: Add IPV6_HDRINCL constant to the socket module (#141818)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 18:07:21 +01:00
Alper
fb26d9c2ef
gh-116738: Make csv module thread-safe (gh-141365)
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.
2025-11-21 11:22:31 -05:00
Pablo Galindo Salgado
b3383085f9
gh-141645: Add a TUI mode to the new tachyon profiler (#141646) 2025-11-20 18:27:17 +00:00
Cody Maloney
e90061f5f1
gh-60107: Remove a copy from RawIOBase.read (#141532)
If the underlying I/O class keeps a reference to the memory, raise BufferError.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-20 17:37:04 +00:00
Victor Stinner
722f4bb8c9
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.
2025-11-20 16:30:35 +00:00
Prithviraj Chaudhuri
b1558b6d3e
gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690) 2025-11-20 15:35:22 +01:00
Brandt Bucher
598d4c64de
GH-140638: Add a GC "duration" stat (GH-141720) 2025-11-19 08:51:39 -08:00
Ayappan Perumal
92c5de73b8
gh-141659: Fix bad file descriptor error in subprocess on AIX (GH-141660)
/proc/self does not exist on AIX.
2025-11-19 09:37:09 +02:00
Victor Stinner
600f3feb23
gh-141070: Add PyUnstable_Object_Dump() function (#141072)
* Promote _PyObject_Dump() as a public function.
* Keep _PyObject_Dump() alias to PyUnstable_Object_Dump()
  for backward compatibility.
* Replace _PyObject_Dump() with PyUnstable_Object_Dump().

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-18 16:13:13 +00:00
Pablo Galindo Salgado
274a26cca8
gh-135953: Simplify GC markers in the tachyon profiler (#141666) 2025-11-17 16:32:08 +00:00