cpython/Include/cpython
Brett Simmers be1dfccdf2
gh-118727: Don't drop the GIL in `drop_gil()` unless the current thread holds it (#118745)
`drop_gil()` assumes that its caller is attached, which means that the current
thread holds the GIL if and only if the GIL is enabled, and the enabled-state
of the GIL won't change. This isn't true, though, because `detach_thread()`
calls `_PyEval_ReleaseLock()` after detaching and
`_PyThreadState_DeleteCurrent()` calls it after removing the current thread
from consideration for stop-the-world requests (effectively detaching it).

Fix this by remembering whether or not a thread acquired the GIL when it last
attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()`
instead of `gil->enabled`.

This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've
reenabled it.
2024-05-23 16:59:35 -04:00
..
abstract.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
bytearrayobject.h gh-89653: PEP 670: Macros always cast arguments in cpython/ (#93766) 2022-06-13 20:09:40 +02:00
bytesobject.h gh-106320: Remove _PyBytes_Join() C API (#107144) 2023-07-23 20:10:12 +00:00
cellobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
ceval.h gh-106320: Remove private _PyEval function (#108433) 2023-08-24 20:25:22 +02:00
classobject.h gh-89653: PEP 670: Convert macros to functions (#99843) 2022-11-28 16:40:08 +01:00
code.h gh-116767: fix crash on 'async with' with many context managers (GH-118348) 2024-05-01 13:01:16 +02:00
compile.h gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412) 2024-04-02 10:34:49 +00:00
complexobject.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
context.h gh-106320: Remove private _PyContext_NewHamtForTests() (#108434) 2023-08-24 19:37:41 +02:00
descrobject.h gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064) 2023-07-22 20:57:59 +00:00
dictobject.h gh-117657: Fixes a few small TSAN issues in dictobject (#118200) 2024-04-25 08:53:29 -07:00
fileobject.h gh-106320: Remove private _Py_UniversalNewlineFgetsWithSize() (#108602) 2023-08-29 02:36:50 +00:00
fileutils.h bpo-46303: Move fileutils.h private functions to internal C API (GH-30484) 2022-01-11 11:56:16 +01:00
floatobject.h gh-89653: PEP 670: Convert macros to functions (#99843) 2022-11-28 16:40:08 +01:00
frameobject.h gh-74929: Implement PEP 667 (GH-115153) 2024-05-04 12:12:10 +01:00
funcobject.h gh-119180: PEP 649: Add __annotate__ attributes (#119209) 2024-05-22 04:38:12 +02:00
genobject.h gh-106320: Move private _PyGen API to the internal C API (#107032) 2023-07-22 14:21:16 +00:00
import.h GH-108716: Turn off deep-freezing of code objects. (GH-108722) 2023-09-08 10:34:40 +01:00
initconfig.h gh-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` (#116338) 2024-03-11 11:02:58 -04:00
listobject.h gh-112087: Make list_repr and list_length to be thread-safe (gh-114582) 2024-01-27 01:20:21 +09:00
longintrepr.h gh-116869: Make C API compatible with ISO C90 (#116950) 2024-03-18 20:16:58 +01:00
longobject.h gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just *endianness* (GH-116053) 2024-04-05 16:21:16 +02:00
memoryobject.h gh-106320: Remove private _PyManagedBuffer_Type (#108431) 2023-08-24 19:07:54 +02:00
methodobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
monitoring.h gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (#119216) 2024-05-21 20:42:51 +00:00
object.h gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454) 2024-05-06 10:50:35 -07:00
objimpl.h gh-102013: Move PyUnstable_GC_VisitObjects() to Include/cpython/objimpl.h (#115560) 2024-02-16 15:49:13 +01:00
odictobject.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
optimizer.h gh-118771: Ensure names defined in optimizer.h start with Py/_Py (GH-118825) 2024-05-10 18:20:12 +02:00
picklebufobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
pthread_stubs.h GH-110829: Ensure Thread.join() joins the OS thread (#110848) 2023-11-04 13:59:24 +00:00
pyatomic.h gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454) 2024-05-06 10:50:35 -07:00
pyatomic_gcc.h gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454) 2024-05-06 10:50:35 -07:00
pyatomic_msc.h gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454) 2024-05-06 10:50:35 -07:00
pyatomic_std.h gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454) 2024-05-06 10:50:35 -07:00
pyctype.h bpo-43816: Add extern "C" to Include/cpython/pyctype.h (GH-25365) 2021-04-13 13:27:21 +02:00
pydebug.h gh-77782: Deprecate global configuration variable (#93943) 2022-06-17 16:12:00 +02:00
pyerrors.h gh-116809: Restore removed _PyErr_ChainExceptions1() function (#116900) 2024-03-16 21:37:11 +01:00
pyfpe.h
pyframe.h gh-74929: Implement PEP 667 (GH-115153) 2024-05-04 12:12:10 +01:00
pyhash.h gh-111389: Add PyHASH_MULTIPLIER constant (#119214) 2024-05-21 19:51:51 +02:00
pylifecycle.h gh-117649: Raise ImportError for unsupported modules in free-threaded build (#117651) 2024-04-11 15:00:54 -04:00
pymem.h gh-90815: Add mimalloc memory allocator (#109914) 2023-10-30 15:43:11 +00:00
pystate.h gh-118727: Don't drop the GIL in `drop_gil()` unless the current thread holds it (#118745) 2024-05-23 16:59:35 -04:00
pystats.h gh-115178: Add Counts of UOp Pairs to pystats (GH-115181) 2024-04-16 14:27:18 +01:00
pythonrun.h gh-106320: Remove private pythonrun API (#108599) 2023-08-29 04:18:52 +02:00
pythread.h gh-110014: Remove PY_TIMEOUT_MAX from limited C API (#110217) 2023-10-02 18:07:56 +02:00
pytime.h gh-110850: Add PyTime_TimeRaw() function (#118394) 2024-05-01 18:05:01 +00:00
setobject.h gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053) 2024-04-19 06:40:28 +09:00
sysmodule.h gh-106560: Fix redundant declarations in Include/ (#112611) 2023-12-03 12:16:31 +01:00
traceback.h gh-106320: Remove private _PyTraceback functions (#108453) 2023-08-24 23:35:47 +00:00
tracemalloc.h gh-106320: Remove private _PyTraceMalloc C API functions (#106324) 2023-07-02 00:49:18 +00:00
tupleobject.h gh-106320: Remove _PyTuple_MaybeUntrack() C API (#107143) 2023-07-23 19:16:21 +00:00
unicodeobject.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
warnings.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
weakrefobject.h gh-118789: Restore hidden `_PyWeakref_ClearRef` (#118797) 2024-05-10 15:54:18 +02:00