cpython/Include/internal
Victor Stinner 82a18069a1
[3.11] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#109272)
gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

(cherry picked from commit 517cd82ea7)
2023-09-11 19:33:08 +02:00
..
pycore_abstract.h
pycore_accu.h
pycore_asdl.h
pycore_ast.h
pycore_ast_state.h [3.11] gh-95185: Check recursion depth in the AST constructor (GH-95186) (GH-95208) 2022-07-26 12:19:22 +02:00
pycore_atomic.h Fix typo in internal/pycore_atomic.h (GH-95939) 2022-08-12 21:04:06 -07:00
pycore_atomic_funcs.h
pycore_bitutils.h
pycore_blocks_output_buffer.h
pycore_bytes_methods.h
pycore_bytesobject.h
pycore_call.h
pycore_ceval.h [3.11] gh-90473: Reduce recursion limit on WASI even further (GH-94333) (GH-94334) 2022-06-27 18:33:01 +02:00
pycore_code.h [3.11] GH-94739: Backport GH-94958 to 3.11 (#94965) 2022-07-25 12:11:06 +01:00
pycore_compile.h
pycore_condvar.h
pycore_context.h
pycore_dict.h gh-46845: clean up unused DK_IXSIZE (GH-96405) 2022-08-30 00:28:51 -07:00
pycore_dtoa.h
pycore_emscripten_signal.h
pycore_exceptions.h
pycore_fileutils.h [3.11] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107982) 2023-08-15 19:07:52 +02:00
pycore_floatobject.h
pycore_format.h [3.11] gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107) (#104260) 2023-05-07 05:06:06 +00:00
pycore_frame.h [3.11] gh-99110: Initialize frame->previous in init_frame to fix segmentation fault (GH-100182) (#100478) 2022-12-24 11:17:10 +05:30
pycore_function.h
pycore_gc.h
pycore_genobject.h
pycore_getopt.h
pycore_gil.h
pycore_global_objects.h
pycore_global_strings.h [3.11] gh-91162: Support splitting of unpacked arbitrary-length tuple over TypeVar and TypeVarTuple parameters (alt) (GH-93412) (GH-93746) 2022-06-14 21:15:56 +03:00
pycore_hamt.h
pycore_hashtable.h
pycore_import.h
pycore_initconfig.h [3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500) 2022-09-02 09:48:57 -07:00
pycore_interp.h [3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500) 2022-09-02 09:48:57 -07:00
pycore_interpreteridobject.h
pycore_list.h
pycore_long.h gh-95778: Correctly pre-check for int-to-str conversion (GH-96537) 2022-09-04 09:45:02 -07:00
pycore_moduleobject.h
pycore_namespace.h
pycore_object.h
pycore_opcode.h [3.11] GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121) (GH-95143) 2022-07-22 11:56:10 -07:00
pycore_parser.h
pycore_pathconfig.h
pycore_pyarena.h
pycore_pyerrors.h
pycore_pyhash.h
pycore_pylifecycle.h
pycore_pymath.h
pycore_pymem.h
pycore_pystate.h [3.11] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#109272) 2023-09-11 19:33:08 +02:00
pycore_runtime.h
pycore_runtime_init.h [3.11] gh-91162: Support splitting of unpacked arbitrary-length tuple over TypeVar and TypeVarTuple parameters (alt) (GH-93412) (GH-93746) 2022-06-14 21:15:56 +03:00
pycore_signal.h
pycore_sliceobject.h
pycore_strhex.h
pycore_structseq.h
pycore_symtable.h
pycore_sysmodule.h
pycore_traceback.h
pycore_tuple.h
pycore_typeobject.h
pycore_ucnhash.h
pycore_unicodeobject.h
pycore_unionobject.h
pycore_warnings.h