cpython/Misc
Vincent Fazio 72123063dd
gh-130115: fix thread identifiers for 32-bit musl (#130391)
CPython's pthread-based thread identifier relies on pthread_t being able
to be represented as an unsigned integer type.

This is true in most Linux libc implementations where it's defined as an
unsigned long, however musl typedefs it as a struct *.

If the pointer has the high bit set and is cast to PyThread_ident_t, the
resultant value can be sign-extended [0]. This can cause issues when
comparing against threading._MainThread's identifier. The main thread's
identifier value is retrieved via _get_main_thread_ident which is backed
by an unsigned long which truncates sign extended bits.

  >>> hex(threading.main_thread().ident)
  '0xb6f33f3c'
  >>> hex(threading.current_thread().ident)
  '0xffffffffb6f33f3c'

Work around this by conditionally compiling in some code for non-glibc
based Linux platforms that are at risk of sign-extension to return a
PyLong based on the main thread's unsigned long thread identifier if the
current thread is the main thread.

[0]: https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Arrays-and-pointers-implementation.html

---------

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2025-04-04 16:31:37 +02:00
..
mypy gh-131507: Clean up tests and type checking for _pyrepl (#131509) 2025-03-21 15:48:10 +01:00
NEWS.d gh-130115: fix thread identifiers for 32-bit musl (#130391) 2025-04-04 16:31:37 +02:00
rhel7
ACKS Update cryptographic CODEOWNERS entry (#131892) 2025-03-30 10:55:05 -07:00
externals.spdx.json gh-129917: Update installers to use SQLite 3.49.1 (#131025) 2025-03-31 23:13:17 +02:00
HISTORY
indent.pro
platform_triplet.c
Porting
python-config.in
python-config.sh.in
python-embed.pc.in
python.man Correct typo in GH-129623 (#130079) 2025-02-14 16:27:17 +00:00
python.pc.in
README
README.AIX
README.valgrind
sbom.spdx.json gh-131261: expat/refresh.sh: Expand list of manual steps (GH-131359) 2025-03-18 13:17:43 +01:00
SpecialBuilds.txt GH-129763: Remove the LLTRACE macro (GH-129764) 2025-02-07 08:49:51 -08:00
stable_abi.toml gh-130947: Add again PySequence_Fast() to the limited C API (#130948) 2025-03-13 13:00:57 +01:00
svnmap.txt
valgrind-python.supp
vgrindefs

Python Misc subdirectory
========================

This directory contains files that wouldn't fit in elsewhere.  Some
documents are only of historic importance.

Files found here
----------------

ACKS                    Acknowledgements
HISTORY                 News from previous releases -- oldest last
indent.pro              GNU indent profile approximating my C style
NEWS                    News for this release (for some meaning of "this")
Porting                 Mini-FAQ on porting to new platforms
python-config.in        Python script template for python-config
python.man              UNIX man page for the python interpreter
python.pc.in            Package configuration info template for pkg-config
README                  The file you're reading now
README.AIX              Information about using Python on AIX
README.valgrind         Information for Valgrind users, see valgrind-python.supp
SpecialBuilds.txt       Describes extra symbols you can set for debug builds
svnmap.txt              Map of old SVN revs and branches to hg changeset ids,
                        help history-digging
valgrind-python.supp    Valgrind suppression file, see README.valgrind
vgrindefs               Python configuration for vgrind (a generic pretty printer)