File tree 4 files changed +23
-0
lines changed
4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
131
131
PyAPI_FUNC (void ) PyThreadState_Delete (PyThreadState * );
132
132
#ifdef WITH_THREAD
133
133
PyAPI_FUNC (void ) PyThreadState_DeleteCurrent (void );
134
+ PyAPI_FUNC (void ) _PyGILState_Reinit (void );
134
135
#endif
135
136
136
137
PyAPI_FUNC (PyThreadState * ) PyThreadState_Get (void );
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ What's New in Python 3.2.1?
10
10
Core and Builtins
11
11
-----------------
12
12
13
+ - Issue #10517: After fork(), reinitialize the TLS used by the PyGILState_*
14
+ APIs, to avoid a crash with the pthread implementation in RHEL 5. Patch
15
+ by Charles-François Natali.
16
+
13
17
- Issue #6780: fix starts/endswith error message to mention that tuples are
14
18
accepted too.
15
19
Original file line number Diff line number Diff line change 991
991
PyOS_AfterFork (void )
992
992
{
993
993
#ifdef WITH_THREAD
994
+ _PyGILState_Reinit ();
994
995
PyEval_ReInitThreads ();
995
996
main_thread = PyThread_get_thread_ident ();
996
997
main_pid = getpid ();
Original file line number Diff line number Diff line change @@ -585,6 +585,23 @@ _PyGILState_Fini(void)
585
585
autoInterpreterState = NULL ;
586
586
}
587
587
588
+ /* Reset the TLS key - called by PyOS_AfterFork.
589
+ * This should not be necessary, but some - buggy - pthread implementations
590
+ * don't flush TLS on fork, see issue #10517.
591
+ */
592
+ void
593
+ _PyGILState_Reinit (void )
594
+ {
595
+ PyThreadState * tstate = PyGILState_GetThisThreadState ();
596
+ PyThread_delete_key (autoTLSkey );
597
+ if ((autoTLSkey = PyThread_create_key ()) == -1 )
598
+ Py_FatalError ("Could not allocate TLS entry" );
599
+
600
+ /* re-associate the current thread state with the new key */
601
+ if (PyThread_set_key_value (autoTLSkey , (void * )tstate ) < 0 )
602
+ Py_FatalError ("Couldn't create autoTLSkey mapping" );
603
+ }
604
+
588
605
/* When a thread state is created for a thread by some mechanism other than
589
606
PyGILState_Ensure, it's important that the GILState machinery knows about
590
607
it so it doesn't try to create another thread state for the thread (this is
You can’t perform that action at this time.
0 commit comments