Commit graph

15017 commits

Author SHA1 Message Date
Kumar Aditya
bc5a028c13
gh-127945: fix thread safety of creating instances of ctypes structures (#131716) 2025-03-30 15:22:30 +05:30
Steve Dower
d260631be0
gh-131423: Update to OpenSSL 3.0.16. (GH-131839)
The bin tag is 3.0.16.1 because we rebuilt without uplink support to fix gh-131804.
This PR also prevents making calls that are now unsafe without uplink, and updates
the tests to property interpret these failures as unsupported.
2025-03-28 15:07:57 +00:00
Michael Droettboom
8614f86b71
gh-131525: Cache the result of tuple_hash (#131529)
* gh-131525: Cache the result of tuple_hash

* Fix debug builds

* Add blurb

* Fix formatting

* Pre-compute empty tuple singleton

* Mostly set the cache within tuple_alloc

* Fixes for TSAN

* Pre-compute empty tuple singleton

* Fix for 32-bit platforms

* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE

* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro

* Update Include/internal/pycore_tuple.h

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

* Fix alignment

* atomic load

* Update Objects/tupleobject.c

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-27 09:57:06 -04:00
Sam Gross
67fbfb42bd
gh-131586: Avoid refcount contention in some "special" calls (#131588)
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to
reference count contention on the returned function object becuase it
doesn't use stackrefs. Refactor some of the callers to use
`_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally.

This fixes the scaling bottleneck in the "lookup_special" microbenchmark
in `ftscalingbench.py`. However, the are still some uses of
`_PyObject_LookupSpecial()` that need to be addressed in future PRs.
2025-03-26 14:38:47 -04:00
Peter Bierma
90b82f2b61
gh-129900: Fix SystemExit return codes when the REPL is started from the command line (#129901) 2025-03-25 19:48:46 +00:00
Kumar Aditya
f1967e7249
gh-127945: fix thread safety of ctypes state (#131710)
This fixes thread safety of `array_cache` and `swapped_suffix` by initializing them in module exec to make it thread safety.
2025-03-25 17:03:05 +05:30
Kumar Aditya
96ef4c511f
gh-127945: add locking to malloc closure in free-threading (#131662)
The freelist is not thread safe in free-threading so this adds lock around it make it thread safe in free-threading.
2025-03-25 16:48:46 +05:30
Victor Stinner
5fef4ff9ed
gh-111178: Fix function signature in pyexpat.c (#131674)
Move _Py_NO_SANITIZE_UNDEFINED macro from faulthandler.c to pyport.h.
2025-03-24 17:22:45 +00:00
Victor Stinner
69e94e0a1b
gh-111178: Fix function signatures for test_socket (#131667)
Add unicode_fsdecode() wrapper for PyUnicode_DecodeFSDefault() to use
the correct API for Py_BuildValue() converter API.
2025-03-24 14:51:32 +00:00
Victor Stinner
6226edc48b
gh-111178: Fix function signatures for test_capi (#131659)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-24 14:04:45 +00:00
Victor Stinner
78f1bac7f2
gh-111178: Fix function signature for test_threading (#131663) 2025-03-24 13:56:45 +00:00
Victor Stinner
4596666a9f
gh-111178: Fix function signatures for test_zoneinfo (#131664) 2025-03-24 14:32:46 +01:00
Victor Stinner
abcd9d4f7d
gh-111178: Fix function signatures for test_ctypes (#131660) 2025-03-24 14:30:13 +01:00
Petr Viktorin
0e53038ea8
gh-128715: Expose ctypes.CField, with info attributes (GH-128950)
- Restore max field size to sys.maxsize, as in Python 3.13 & below
- PyCField: Split out bit/byte sizes/offsets.
- Expose CField's size/offset data to Python code
- Add generic checks for all the test structs/unions, using the newly exposed attrs
2025-03-24 14:18:34 +01:00
Sergey Miryanov
62fb15d866
gh-131311: Extract _replace_array_elements from PyCStructUnionType_update_stginfo (GH-131504) 2025-03-24 13:55:09 +01:00
Kumar Aditya
04d4aacaac
gh-128485: ensure that dlmalloc initializes itself at import time in ctypes (#131633) 2025-03-24 18:14:25 +05:30
Sergey Miryanov
9c4fb92e12
gh-131311: Fix additional memory leaks in ctypes (GH-131429)
* Visit keep in StructParam_traverse
* Decref swapped in PyCSimpleType_init
* Decref ob in make_funcptrtype_dict
* Check Pointer_item result while constructing result list in Pointer_subscript

* Fix align and size naming in PyCStructUnionType_update_stginfo
  - as discussed in previous PR
2025-03-24 13:42:10 +01:00
Bénédikt Tran
af29d5cfd1
gh-111178: fix UBSan failures for Modules/_testcapimodule.c (#131614)
Fix UBSan failures for various classes in `Modules/_testcapimodule.c`,
remove some redundant casts and add some `Py_UNUSED()` usages.
2025-03-24 10:14:22 +00:00
Bénédikt Tran
491b8141f5
gh-111178: fix UBSan failures for Modules/_testcapi/{buffer,monitoring}.c (#131613) 2025-03-24 11:06:37 +01:00
Bénédikt Tran
45191797d8
gh-111178: fix UBSan failures for Modules/_testmultiphase.c (#131615) 2025-03-24 10:59:30 +01:00
Bénédikt Tran
82e541bf91
gh-111178: fix UBSan failures for Modules/_testbuffer.c (#131612) 2025-03-24 10:46:25 +01:00
Bénédikt Tran
ef06508f8e
gh-111178: fix UBSan failures for TaskStepMethWrapper (#131602) 2025-03-23 19:56:03 +05:30
Bénédikt Tran
a9a399f0ec
gh-131418: remove unused legacy typedefs in {md5,sha1}module.c (#131420)
- Remove legacy typedefs `MD5_INT32` and `MD5_INT64` in `Modules/md5module.c`
- Remove legacy typedefs `SHA1_INT32` and `SHA1_INT64` in `Modules/sha1module.c`.

Those legacy typedefs were used to detect whether the host platform could
correctly implement MD5 and SHA-1, but this is no longer needed as we now
fallback to HACL* implementations.
2025-03-23 12:19:26 +01:00
Chris Eibl
bc26f95e8f
GH-131296: fix clang-cl warning on Windows in semaphore.c (GH-131595)
fix clangcl warning
2025-03-22 15:44:56 -07:00
Victor Stinner
1a082085ae
gh-131238: Remove pycore_object_deferred.h from pycore_object.h (#131549)
Remove also pycore_function.h from pycore_typeobject.h.
2025-03-21 16:44:10 +00:00
Xavier G.
b70d45ab22
gh-131268: Implement thread names on OpenBSD (#131528) 2025-03-21 11:12:35 +01:00
Stan Ulbrych
e0fda794fa
gh-70647: Raise a more informative error for when date is out of range (GH-131335)
More informative error messages mean less debugging what went wrong.
2025-03-20 20:47:09 -07:00
Mark Shannon
7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Victor Stinner
b69da006a4
gh-131238: Remove includes from pycore_interp.h (#131495)
Remove also now unused includes in C files.
2025-03-20 11:35:23 +00:00
Victor Stinner
34c1ea3109
gh-111178: Fix function signatures for multiple tests (#131496) 2025-03-20 12:27:03 +01:00
Victor Stinner
486d537065
Fix Windows build warnings (#131487)
Fix the following warnings:

* Modules\_io\fileio.c(1296,13): unused variable 'self'
* Modules\_io\winconsoleio.c(334,9): unused variable 'fd_is_own'
* Modules\faulthandler.c(409,11): unused variable 'flags'
* Modules\posixmodule.c(5699,9): unused variable 'pathError'
* PC\winreg.c(2077,5): suggest braces around initialization of
  subobject
* PC\winreg.c(34,13): unused variable 'errNotAHandle'
* Python\fileutils.c(132,12): result of comparison of constant
  1114111 with expression of type 'wchar_t' (aka 'unsigned short') is
  always false
* Python\fileutils.c(58,21): unused variable 'INCOMPLETE_CHARACTER'
* Python\sysmodule.c(2534,21): unused variable 'perf_map_state'
2025-03-20 12:03:20 +01:00
Victor Stinner
20c5f969dd
gh-131238: Remove more includes from pycore_interp.h (#131480) 2025-03-19 23:01:32 +01:00
Steve Dower
63a638c43f
gh-91349: Replace zlib with zlib-ng in Windows build (GH-131438) 2025-03-19 19:03:25 +00:00
Victor Stinner
5c44d7d99c
gh-130931: Add pycore_interpframe.h internal header (#131249)
Move _PyInterpreterFrame and associated functions
to a new pycore_interpframe.h header.
2025-03-19 18:17:44 +01:00
Victor Stinner
4b54031323
gh-131238: Remove pycore_runtime.h from pycore_pystate.h (#131356)
* Remove includes from pycore_pystate.h:

  * pycore_runtime_structs.h
  * pycore_runtime.h
  * pycore_tstate.h
  * pycore_interp.h

* Reorganize internal headers. Move _gc_thread_state from
  pycore_interp_structs.h to pycore_tstate.h.
* Add 3 new header files to PCbuild/pythoncore.vcxproj.
2025-03-19 17:33:24 +01:00
Victor Stinner
6935d96e9c
gh-111178: Fix function signatures in _testbuffer.c (#131463) 2025-03-19 16:54:18 +01:00
Victor Stinner
f5e4c2955b
gh-111178: Fix function signatures for test_iter (#131456) 2025-03-19 14:42:51 +01:00
Max Bachmann
49234c065c
gh-114917: Fix typo in getaddrinfo emulation (#131413) 2025-03-18 14:31:13 +01:00
Petr Viktorin
51d309988b
gh-131261: expat/refresh.sh: Expand list of manual steps (GH-131359) 2025-03-18 13:17:43 +01:00
Sergey Miryanov
812074e291
gh-131311: Consolidate reference handling in PyCStructUnionType_update_stginfo to fix memory leak (GH-131312) 2025-03-18 11:50:22 +01:00
Max Bachmann
3453b5c1d6
gh-114917: add support for AI_NUMERICSERV in getaddrinfo emulation (#114918) 2025-03-18 11:26:51 +01:00
Tomasz Pytel
863d54cbaf
gh-126895: Fix readline module in free-threaded build (#131208)
The underlying readline library is not thread-safe so this adds `@critical_section` to functions that use it.
2025-03-17 11:57:11 -04:00
Bénédikt Tran
e708ac8dd4
gh-111178: fix UBSan failures in Modules/_ssl.c (GH-130719)
* fix UBSan failures for `PySSLContext`, `PySSLSocket`, `PySSLMemoryBIO`, `PySSLSession`
2025-03-17 16:25:28 +01:00
Mark Shannon
a45f25361d
GH-131238: More refactoring of core header files (GH-131351)
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Gregory P. Smith
bb0268f60d
gh-131261: Update libexpat to 2.7.0 (CVE-2024-8176) (#131272) 2025-03-17 14:55:02 +01:00
Victor Stinner
978e37bb5f
gh-131238: Add explicit includes to pycore headers (#131257) 2025-03-17 12:32:43 +01:00
Bénédikt Tran
ac50ece6ce
gh-127667: refactor and improve _hashopenssl.c error branches (#131145)
Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
2025-03-17 11:12:55 +01:00
Bénédikt Tran
261633bd3f
gh-131316: handle NULL values returned by HACL* functions (#131324)
- Handle NULL returned by allocation functions.
- Handle NULL returned by copy functions.
- Suppress unused impossible return codes.
2025-03-17 11:10:39 +01:00
Mark Shannon
a1aeec61c4
GH-131238: Core header refactor (GH-131250)
* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h

* Removes many cross-header dependencies
2025-03-17 09:19:04 +00:00
Chris Eibl
faa80fcf46
GH-131296: fix clang-cl warnings on Windows in blake2module.c (#131299)
work around unimportant clang-cl warnings in blake2module.c
2025-03-15 11:37:53 -07:00