cpython/Modules
Pablo Galindo Salgado 4ed40146f1
gh-149202: Fix frame pointer unwinding on s390x and ARM (GH-149362)
-fno-omit-frame-pointer is not enough to make every target walkable by the
simple manual frame pointer unwinder.

The helper used by test_frame_pointer_unwind used to assume the frame pointer
named a two-word record where fp[0] was the previous frame pointer and fp[1]
was the return address. That is only the generic layout used by some targets.
This patch keeps that default, but moves the slots behind named offsets so
architecture-specific layouts can describe where the backchain and return
address really live.

On s390x, GCC and Clang do not emit a usable backchain unless -mbackchain is
enabled. Without it, the unwinder stops at the current C frame and the test
reports no Python frames. Once backchains are present, the helper must also
stop at the current thread's known C stack bounds; otherwise it can follow the
final backchain far enough to dereference an invalid frame and segfault.
For Linux s390x backchain frames, the documented z/Architecture stack-frame
layout saves r14, the return-address register, at byte offset 112 from the
frame pointer, so read the return address from that named slot instead of fp[1].

The 112-byte offset comes from Linux's s390 debugging documentation: its Stack
Frame Layout table shows z/Architecture backchain frames with the backchain at
offset 0 and saved r14 of the caller function at offset 112:
https://www.kernel.org/doc/html/v5.3/s390/debugging390.html#stack-frame-layout

This helper remains scoped to Linux s390x backchain frames. GNU SFrame's s390x
notes state that the s390x ELF ABI does not generally mandate where RA and FP
are saved, or whether they are saved at all:
https://sourceware.org/binutils/docs/sframe-spec.html#s390x

As Jens Remus noted, -fno-omit-frame-pointer is not needed when -mbackchain is
present.

On 32-bit ARM, GCC defaults to Thumb mode on common armhf toolchains. The Thumb
prologue keeps the saved frame pointer and link register at offsets that depend
on the generated frame, which breaks the fp[0]/fp[1] walk used by the helper.
Use -marm when it is supported for frame-pointer builds, and teach the helper
the GCC ARM-mode slots where the previous frame pointer is at fp[-1] and the
saved LR return address is at fp[0].


Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-06 15:03:37 +00:00
..
_ctypes gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct (#148676) 2026-05-04 16:14:23 +02:00
_decimal GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
_hacl gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188) 2025-10-16 05:25:51 +00:00
_io gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_multiprocessing gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_remote_debugging gh-149009: Validate thread_count in profiling.sampling binary reader (#149147) 2026-05-05 00:50:06 +00:00
_sqlite gh-146090: fix memory management of internal sqlite3 callback contexts (#146569) 2026-03-29 14:21:37 +02:00
_sre GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
_ssl gh-146207: Add support for OpenSSL 4.0.0 alpha1 (#146217) 2026-03-25 07:44:47 +01:00
_testcapi gh-149216: Notify type watchers on heap type deallocation (GH-149236) 2026-05-05 11:24:07 +01:00
_testinternalcapi GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
_testlimitedcapi gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
_xxtestfuzz Update and expand the 'Fuzz Tests for CPython' README (#148270) 2026-04-09 08:52:30 +01:00
_zstd gh-146578: _zstd: Fix printf format for pledged size errors (#146576) 2026-04-21 12:49:44 -07:00
cjkcodecs GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003) 2026-04-02 23:24:03 +02:00
clinic gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct (#148676) 2026-05-04 16:14:23 +02:00
expat gh-149017: Upgrade bundled Expat to 2.8.0 (#149020) 2026-04-27 21:22:35 +01:00
_abc.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_asynciomodule.c gh-148274: properly handle result from PyObject_VisitManagedDict (#148275) 2026-04-09 18:50:50 +05:30
_bisectmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_bz2module.c gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) 2026-04-12 18:14:54 -07:00
_codecsmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_collectionsmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_csv.c gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) 2026-04-11 15:18:02 -07:00
_curses_panel.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_cursesmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_datetimemodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003) 2026-04-02 23:24:03 +02:00
_dbmmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_elementtree.c gh-148735: Fix a UAF in Element.findtext() (#148738) 2026-04-23 15:48:00 +01:00
_functoolsmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_gdbmmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_hashopenssl.c gh-146287: Fix signed/unsigned mismatch in _hashlib_hmac_digest_size (GH-148407) 2026-04-12 00:02:56 +00:00
_heapqmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_interpchannelsmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_interpqueuesmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_interpreters_common.h gh-132775: Use _PyObject_GetXIData (With Fallback) (gh-134440) 2025-05-22 06:50:06 -06:00
_interpretersmodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003) 2026-04-02 23:24:03 +02:00
_json.c gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) 2026-04-12 00:14:50 +00:00
_localemodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_lsprof.c gh-145846: Fix memory leak in _lsprof clearEntries() context chain (#145847) 2026-04-07 22:56:19 +02:00
_lzmamodule.c gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) 2026-04-12 18:14:54 -07:00
_math.h gh-122681: remove m_atan2()/c_atan2() helpers (#122715) 2024-08-17 13:48:16 +05:30
_opcode.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_operator.c GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
_pickle.c GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
_posixsubprocess.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_queuemodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_randommodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_scproxy.c gh-116322: Add Py_mod_gil module slot (#116882) 2024-05-03 11:30:55 -04:00
_ssl.c gh-148292: Update _ssl._SSLSocket for OpenSSL 4 (#149102) 2026-05-04 13:52:57 +02:00
_ssl.h GH-103092: isolate _ssl (#104725) 2023-05-22 06:14:48 +05:30
_ssl_data_36.h gh-149254: Update CI to use latest OpenSSL and AWS-LC versions (GH-149330) 2026-05-03 20:20:51 +00:00
_ssl_data_40.h gh-148600: Add Modules/_ssl_data_40.h data (#148601) 2026-04-15 15:59:02 +02:00
_ssl_data_111.h gh-131423: Update OpenSSL data to 3.4.1 on Linux (#131618) 2025-04-25 10:26:58 +02: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
_ssl_data_340.h gh-131423: Update OpenSSL data to 3.4.1 on Linux (#131618) 2025-04-25 10:26:58 +02:00
_stat.c gh-108765: fix comment about macro definitions in _stat.c post GH-108854 (#136027) 2025-06-27 15:15:11 +00:00
_statisticsmodule.c gh-116322: Add Py_mod_gil module slot (#116882) 2024-05-03 11:30:55 -04:00
_struct.c gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct (#148676) 2026-05-04 16:14:23 +02:00
_suggestions.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_sysconfig.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_testbuffer.c gh-146151: memoryview supports 'F' and 'D' format types (complex) (#146241) 2026-03-26 15:26:34 +01:00
_testcapi_feature_macros.inc gh-91325: Skip Stable ABI checks with Py_TRACE_REFS special build (GH-92046) 2024-01-29 16:45:31 +01:00
_testcapimodule.c gh-148274: properly handle result from PyObject_VisitManagedDict (#148275) 2026-04-09 18:50:50 +05:30
_testclinic.c gh-144545: Improve handling of default values in Argument Clinic (GH-146016) 2026-03-17 12:16:35 +02:00
_testclinic_limited.c gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL (GH-118645) 2024-05-06 18:59:36 +02:00
_testimportmultiple.c gh-116322: Add Py_mod_gil module slot (#116882) 2024-05-03 11:30:55 -04:00
_testinternalcapi.c gh-149202: Fix frame pointer unwinding on s390x and ARM (GH-149362) 2026-05-06 15:03:37 +00:00
_testlimitedcapi.c gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
_testmultiphase.c gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
_testsinglephase.c gh-145921: Add "_DuringGC" functions for tp_traverse (GH-145925) 2026-04-08 09:15:11 +02:00
_threadmodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
_tkinter.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_tracemalloc.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_typesmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_typingmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_uuidmodule.c gh-132710: only use stable _uuid.generate_time_safe() to deduce MAC address (#132901) 2025-05-26 10:56:31 +02:00
_weakref.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_winapi.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_zoneinfo.c gh-145883: Fix two heap-buffer-overflows in _zoneinfo (#145885) 2026-04-04 13:29:17 +01:00
addrinfo.h gh-114917: add support for AI_NUMERICSERV in getaddrinfo emulation (#114918) 2025-03-18 11:26:51 +01:00
arraymodule.c gh-148675: Optimize arraydescr structure: use char[3] (GH-149455) 2026-05-06 16:28:11 +02:00
atexitmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
binascii.c gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) 2026-05-04 12:40:52 +03:00
blake2module.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
cmathmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
config.c.in gh-128384: Use a context variable for warnings.catch_warnings (gh-130010) 2025-04-09 16:18:54 -07:00
errnomodule.c gh-126585: Add EHWPOISON error code (#126586) 2024-12-03 12:45:50 +00:00
faulthandler.c gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() (#148145) 2026-05-06 15:01:12 +00:00
fcntlmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
gc_weakref.txt GH-135552: Make the GC clear weakrefs later (GH-136189) 2025-08-07 16:32:17 -07:00
gcmodule.c GH-148726: Forward-port generational GC. (GH-148746) 2026-04-30 12:19:13 -07:00
getaddrinfo.c gh-114917: Fix typo in getaddrinfo emulation (#131413) 2025-03-18 14:31:13 +01:00
getbuildinfo.c gh-100388: Change undefined __DATE__ to the Unix epoch (#100389) 2025-03-03 14:59:46 +01:00
getnameinfo.c Replace K&R function declarations with ANSI declarations (#114818) 2025-03-11 13:06:36 +01:00
getpath.c GH-131296: Avoid invalid signed char comparison in getpath.c assertion (GH-131594) 2025-04-22 14:06:30 +01:00
getpath.py GH-145273: don't skip missing platstdlib warning if stdlib_zip is found (#145544) 2026-03-09 19:37:33 +00:00
getpath_noop.c bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
grpmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
hashlib.h gh-131876: Revert "gh-131876: extract _hashlib helpers into a separate directory (#136995) (#137307) 2025-08-01 10:45:40 -07:00
hmacmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
itertoolsmodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
ld_so_aix.in Issue #10656: Fix out-of-tree building on AIX 2016-11-20 07:56:37 +00:00
main.c GH-145247: Use _PyTuple_FromPair in Modules (part 1) (#148000) 2026-04-02 23:20:13 +02:00
makesetup gh-116943: Ensure makesetup does not choke on missing EOL in Setup.* files (#139100) 2025-09-18 09:25:01 +00:00
makexp_aix bpo-42087: Remove support for AIX 5.3 and below (GH-22830) 2020-11-16 16:16:10 +01:00
mathintegermodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
mathmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
md5module.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
mmapmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
overlapped.c gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (#148809) 2026-04-21 07:29:07 -07:00
posixmodule.c GH-126910: Add gdb support for unwinding JIT frames (#146071) 2026-05-02 13:42:03 +00:00
posixmodule.h gh-85283: Convert grp extension to the limited C API (#116611) 2024-03-12 00:46:53 +00:00
pwdmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
pyexpat.c gh-146563: add exception note for invalid Expat handler return values (#146565) 2026-04-14 19:12:47 +02:00
readline.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
README
resource.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
rotatingtree.c gh-116181: Remove Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE in rotatingtree.c (#121260) 2024-07-03 13:05:05 +05:30
rotatingtree.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
selectmodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003) 2026-04-02 23:24:03 +02:00
Setup GH-146527: Add get_gc_stats function to _remote_debugging (#148071) 2026-05-02 15:04:18 +00:00
Setup.bootstrap.in gh-136421: Load _datetime static types during interpreter initialization (GH-136583) 2025-07-21 13:47:26 -04:00
Setup.stdlib.in gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
sha1module.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
sha2module.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
sha3module.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
signalmodule.c GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003) 2026-04-02 23:24:03 +02:00
socketmodule.c GH-135357: Add socket.SO_PASSRIGHTS constant (#135355) 2026-04-27 13:12:34 +00:00
socketmodule.h gh-86819: Add ISO-TP CAN socket constants (#23794) 2025-09-17 17:18:04 +00:00
symtablemodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
syslogmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
termios.c gh-146091: Fix NULL check in termios.tcsetwinsize (#146147) 2026-03-19 16:20:18 +05:30
timemodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
tkappinit.c gh-103538: Remove unused TK_AQUA code (GH-103539) 2023-05-10 18:53:13 +00:00
tkinter.h gh-103532: Remove TKINTER_PROTECT_LOADTK code (GH-103535) 2023-04-14 09:04:16 -05:00
unicodedata.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
unicodedata_db.h gh-66802: Add unicodedata.block() function (#145042) 2026-02-21 18:27:55 +01:00
unicodename_db.h gh-144882: Optimize name tables in unicodedata by excluding names derived by rule NR2 (GH-144883) 2026-02-18 12:58:21 +02:00
winreparse.h bpo-31512: Add non-elevated symlink support for Windows (GH-3652) 2019-04-09 11:19:46 -07:00
xxlimited.c gh-134160: Add more comments for the xxlimited module (GH-140214) 2025-10-27 11:39:42 +01:00
xxlimited_35.c gh-111178: Fix function signatures for multiple tests (#131496) 2025-03-20 12:27:03 +01:00
xxmodule.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
xxsubtype.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
zlibmodule.c gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) 2026-04-12 18:14:54 -07:00

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