cpython/Modules
Sam Gross 052cb717f5
gh-124878: Fix race conditions during interpreter finalization (#130649)
The PyThreadState field gains a reference count field to avoid
issues with PyThreadState being a dangling pointer to freed memory.
The refcount starts with a value of two: one reference is owned by the
interpreter's linked list of thread states and one reference is owned by
the OS thread. The reference count is decremented when the thread state
is removed from the interpreter's linked list and before the OS thread
calls `PyThread_hang_thread()`. The thread that decrements it to zero
frees the `PyThreadState` memory.

The `holds_gil` field is moved out of the `_status` bit field, to avoid
a data race where on thread calls `PyThreadState_Clear()`, modifying the
`_status` bit field while the OS thread reads `holds_gil` when
attempting to acquire the GIL.

The `PyThreadState.state` field now has `_Py_THREAD_SHUTTING_DOWN` as a
possible value. This corresponds to the `_PyThreadState_MustExit()`
check. This avoids race conditions in the free threading build when
checking `_PyThreadState_MustExit()`.
2025-03-06 10:38:34 -05:00
..
_ctypes gh-128911: Use PyImport_ImportModuleAttr() function (#129657) 2025-02-05 11:03:58 +01:00
_decimal gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) 2025-02-18 09:46:48 +02:00
_hacl gh-127897: fix HACL* build on macOS/Catalina (GH-127932) 2024-12-17 22:14:16 -08:00
_io gh-130790: Remove references about unicode's readiness from comments (#130801) 2025-03-03 19:18:09 +00:00
_multiprocessing gh-111178: fix UBSan failures in Modules/_multiprocessing/semaphore.c (#129084) 2025-01-20 20:43:55 +00:00
_sqlite gh-129928: Rework sqlite3 error helpers (#129929) 2025-02-11 07:49:25 +00:00
_sre gh-129983: fix data race in compile_template in sre.c (#130015) 2025-02-12 18:34:44 +05:30
_ssl gh-111178: fix UBSan failures in Modules/_ssl/cert.c (GH-129088) 2025-01-30 11:11:37 +01:00
_testcapi gh-128911: Use PyImport_ImportModuleAttr() function (#129657) 2025-02-05 11:03:58 +01:00
_testinternalcapi
_testlimitedcapi gh-130824: Clean up test wrappers for PyLong_*AndOverflow functions (GH-130871) 2025-03-05 11:50:53 +01:00
_xxtestfuzz
cjkcodecs gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
clinic Revert "gh-128942: make array module thread safe (#128943)" (#130707) 2025-02-28 16:57:48 -05:00
expat gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) 2024-11-13 18:31:20 +00:00
_abc.c gh-111178: fix UBSan failures in Modules/_abc.c (GH-128253) 2025-01-07 12:45:29 +01:00
_asynciomodule.c gh-128002: use efficient linked list implementation for eager tasks in asyncio (#130518) 2025-03-03 06:36:43 +00:00
_bisectmodule.c
_bz2module.c gh-111178: fix UBSan failures in Modules/_bz2module.c (GH-128238) 2025-01-10 11:47:19 +01:00
_codecsmodule.c
_collectionsmodule.c gh-111178: fix UBSan failures in Modules/_collectionsmodule.c (#129773) 2025-02-17 12:12:03 +00:00
_complex.h
_contextvarsmodule.c
_csv.c gh-129409: Fix Integer overflow - SEGV while writing data more than 2GB in CSV file (#129413) 2025-01-29 11:15:47 +00:00
_curses_panel.c gh-111178: fix UBSan failures in Modules/curses*.c (GH-128244) 2025-01-03 15:12:40 +01:00
_cursesmodule.c gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) 2025-02-25 23:04:27 +02:00
_datetimemodule.c gh-111178: fix UBSan failures in Modules/_datetimemodule.c (GH-129774) 2025-02-19 11:18:37 +00:00
_dbmmodule.c gh-111178: fix UBSan failures in Modules/_dbmmodule.c (#129775) 2025-02-10 11:02:47 +01:00
_elementtree.c gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
_functoolsmodule.c gh-111178: fix UBSan failures in Modules/_functoolsmodule.c (GH-129778) 2025-02-21 15:08:56 +01:00
_gdbmmodule.c gh-111178: fix UBSan failures for gdbmobject (GH-128178) 2025-01-10 11:52:36 +01:00
_hashopenssl.c gh-127667: fix memory leaks in hashlib (#127668) 2025-03-03 09:20:33 +01:00
_heapqmodule.c
_interpchannelsmodule.c gh-111178: fix UBSan failures in Modules/_interp*module.c (GH-129779) 2025-02-17 11:34:14 +01:00
_interpqueuesmodule.c gh-111178: fix UBSan failures in Modules/_interp*module.c (GH-129779) 2025-02-17 11:34:14 +01:00
_interpreters_common.h gh-76785: Improved Subinterpreters Compatibility with 3.12 (2/2) (gh-126707) 2024-11-12 10:41:51 -07:00
_interpretersmodule.c gh-111178: fix UBSan failures in Modules/_interp*module.c (GH-129779) 2025-02-17 11:34:14 +01:00
_json.c gh-111178: fix UBSan failures in Modules/_jsonmodule.c (GH-129781) 2025-02-17 14:51:18 +01:00
_localemodule.c Fix a typo in _localemodule.c (GH-130085) 2025-02-13 17:29:26 +00:00
_lsprof.c gh-111178: fix UBSan failures in Modules/_lsprof.c (GH-129782) 2025-02-17 14:53:03 +01:00
_lzmamodule.c gh-111178: fix UBSan failures in Modules/_lzmamodule.c (GH-129783) 2025-02-18 14:48:21 +01:00
_math.h
_opcode.c gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
_operator.c gh-111178: fix UBSan failures in Modules/_operator.c (GH-129785) 2025-02-20 14:21:55 +01:00
_pickle.c gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) 2025-02-25 23:04:27 +02:00
_posixsubprocess.c
_queuemodule.c gh-111178: fix UBSan failures in Modules/_queuemodule.c (GH-129790) 2025-02-21 14:37:32 +00:00
_randommodule.c gh-111178: fix UBSan failures in Modules/_randommodule.c (GH-129791) 2025-02-21 14:59:04 +00:00
_scproxy.c
_ssl.c gh-129354: Use PyErr_FormatUnraisable() function (#129518) 2025-01-31 15:06:14 +01:00
_ssl.h
_ssl_data_34.h gh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331) 2024-11-28 13:29:27 +01:00
_ssl_data_111.h gh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331) 2024-11-28 13:29:27 +01:00
_ssl_data_300.h gh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331) 2024-11-28 13:29:27 +01:00
_stat.c
_statisticsmodule.c
_struct.c gh-111178: fix UBSan failures in Modules/_struct.c (#129793) 2025-02-23 10:34:11 +00:00
_suggestions.c
_sysconfig.c
_testbuffer.c
_testcapi_feature_macros.inc
_testcapimodule.c GH-130396: Use computed stack limits on linux (GH-130398) 2025-02-25 09:24:48 +00:00
_testclinic.c gh-122943: Remove the object converter for var-positional parameter (GH-126560) 2024-11-08 05:41:54 +00:00
_testclinic_limited.c
_testexternalinspection.c gh-130052: Fix some exceptions on error paths in _testexternalinspection (#130053) 2025-02-20 17:05:39 +00:00
_testimportmultiple.c
_testinternalcapi.c gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553) 2025-02-26 14:55:15 -05:00
_testlimitedcapi.c gh-111495: Add PyFile tests (#129449) 2025-01-30 18:05:32 +01:00
_testmultiphase.c gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406) 2025-02-24 14:59:19 +01:00
_testsinglephase.c
_threadmodule.c gh-124878: Fix race conditions during interpreter finalization (#130649) 2025-03-06 10:38:34 -05:00
_tkinter.c gh-111178: fix UBSan failures in Modules/_tkinter.c (GH-129795) 2025-02-26 09:40:48 +01:00
_tracemalloc.c gh-128679: Redesign tracemalloc locking (#128888) 2025-01-15 20:22:44 +00:00
_typingmodule.c gh-105499: Merge typing.Union and types.UnionType (#105511) 2025-03-04 11:44:19 -08:00
_uuidmodule.c
_weakref.c
_winapi.c gh-111178: fix UBSan failures in Modules/_winapi.c (GH-129796) 2025-02-24 14:06:13 +01:00
_zoneinfo.c gh-111178: fix UBSan failures in Modules/_zoneinfo.c (GH-129798) 2025-02-26 09:36:59 +01:00
addrinfo.h
arraymodule.c Revert "gh-128942: make array module thread safe (#128943)" (#130707) 2025-02-28 16:57:48 -05:00
atexitmodule.c gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475) 2025-01-31 09:45:35 +01:00
binascii.c
blake2module.c gh-111178: fix UBSan failures in Modules/{blake2,md5,sha1,sha2,sha3}module.c (GH-128248) 2025-01-27 14:50:58 +01:00
cmathmodule.c gh-120026: soft deprecate Py_HUGE_VAL macro (#120027) 2024-11-01 22:04:31 +00:00
config.c.in gh-126107: Remove copyright block from Modules/config.c.in (#126982) 2025-01-26 16:57:32 +00:00
errnomodule.c gh-126585: Add EHWPOISON error code (#126586) 2024-12-03 12:45:50 +00:00
faulthandler.c gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) 2025-02-25 23:04:27 +02:00
fcntlmodule.c
gc_weakref.txt
gcmodule.c gh-122943: Rework support of var-positional parameter in Argument Clinic (GH-122945) 2024-11-07 23:40:03 +02:00
getaddrinfo.c
getbuildinfo.c gh-100388: Change undefined __DATE__ to the Unix epoch (#100389) 2025-03-03 14:59:46 +01:00
getnameinfo.c
getpath.c gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475) 2025-01-31 09:45:35 +01:00
getpath.py GH-128469: Revert "warn when libpython was loaded from outside the build directory (#128645)" (#129506) 2025-01-31 11:17:37 +00:00
getpath_noop.c
grpmodule.c gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055) 2024-11-21 15:47:24 +01:00
hashlib.h
itertoolsmodule.c gh-111178: fix UBSan failures in Modules/itertoolsmodule.c (GH-129780) 2025-02-19 11:58:47 +01:00
ld_so_aix.in
main.c gh-128130: Fix unhandled keyboard interrupt data race (gh-129975) 2025-02-13 12:29:03 -05:00
makesetup
makexp_aix
mathmodule.c gh-101410: support custom messages for domain errors in the math module (#124299) 2025-01-23 13:55:25 +00:00
md5module.c gh-111178: fix UBSan failures in Modules/{blake2,md5,sha1,sha2,sha3}module.c (GH-128248) 2025-01-27 14:50:58 +01:00
mmapmodule.c gh-111178: fix clang-cl compilation of Modules/mmapmodule.c post gh-129784 (#130446) 2025-02-22 12:36:38 +01:00
overlapped.c gh-111178: fix UBSan failures in Modules/overlapped.c (GH-129786) 2025-02-20 14:24:24 +01:00
posixmodule.c gh-124878: Fix race conditions during interpreter finalization (#130649) 2025-03-06 10:38:34 -05:00
posixmodule.h
pwdmodule.c
pyexpat.c gh-111178: fix UBSan failures in Modules/pyexpat.c (GH-129789) 2025-02-24 11:56:32 +01:00
readline.c gh-122431: Disallow negative values in readline.append_history_file (#122469) 2024-12-05 16:07:38 +00:00
README
resource.c
rotatingtree.c
rotatingtree.h
selectmodule.c gh-111178: fix UBSan failures in Modules/selectmodule.c (GH-129792) 2025-02-24 13:38:18 +01:00
Setup
Setup.bootstrap.in
Setup.stdlib.in gh-93649: Add Modules/_testcapi/function.c file (#129521) 2025-01-31 16:02:50 +01:00
sha1module.c gh-111178: fix UBSan failures in Modules/{blake2,md5,sha1,sha2,sha3}module.c (GH-128248) 2025-01-27 14:50:58 +01:00
sha2module.c gh-111178: fix UBSan failures in Modules/{blake2,md5,sha1,sha2,sha3}module.c (GH-128248) 2025-01-27 14:50:58 +01:00
sha3module.c gh-111178: fix UBSan failures in Modules/{blake2,md5,sha1,sha2,sha3}module.c (GH-128248) 2025-01-27 14:50:58 +01:00
signalmodule.c gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475) 2025-01-31 09:45:35 +01:00
socketmodule.c gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293) 2025-02-27 12:51:47 +00:00
socketmodule.h
symtablemodule.c
syslogmodule.c gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) 2025-02-25 23:04:27 +02:00
termios.c
timemodule.c gh-130617 : fix time_clockid_converter on DragonFlyBSD (#130634) 2025-02-28 08:56:00 +01:00
tkappinit.c
tkinter.h
unicodedata.c gh-130790: Remove references about unicode's readiness from comments (#130801) 2025-03-03 19:18:09 +00:00
unicodedata_db.h
unicodename_db.h
winreparse.h
xxlimited.c gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797) 2025-02-25 13:02:32 +01:00
xxlimited_35.c gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797) 2025-02-25 13:02:32 +01:00
xxmodule.c gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797) 2025-02-25 13:02:32 +01:00
xxsubtype.c gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797) 2025-02-25 13:02:32 +01:00
zlibmodule.c gh-111178: fix UBSan failures in Modules/zlibmodule.c (GH-128252) 2025-01-03 15:36:41 +01:00

Source files for standard library extension modules,
and former extension modules that are now builtin modules.