Mercurial > cpython-lru_cache-weakref
view Python/formatter_string.c @ 48167:a8a8232cb541 legacy-trunk
Adds a sanity check to avoid a *very rare* infinite loop due to a corrupt tls
key list data structure in the thread startup path.
This change is a companion to r60148 which already successfully dealt with a
similar issue on thread shutdown.
In particular this loop has been observed happening from this call path:
#0 in find_key ()
#1 in PyThread_set_key_value ()
#2 in _PyGILState_NoteThreadState ()
#3 in PyThreadState_New ()
#4 in t_bootstrap ()
#5 in pthread_start_thread ()
I don't know how this happens but it does, *very* rarely. On more than
one hardware platform. I have not been able to reproduce it manually.
(A flaky mutex implementation on the system in question is one hypothesis).
As with r60148, the spinning we managed to observe in the wild was due to a
single list element pointing back upon itself.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 04 Aug 2008 07:33:37 +0000 |
| parents | 47ef9a806ce9 |
| children | 34e7c1b14495 |
line wrap: on
line source
/***********************************************************************/ /* Implements the string (as opposed to unicode) version of the built-in formatters for string, int, float. That is, the versions of int.__float__, etc., that take and return string objects */ #include "Python.h" #include "../Objects/stringlib/stringdefs.h" #define FORMAT_STRING _PyBytes_FormatAdvanced #define FORMAT_LONG _PyLong_FormatAdvanced #define FORMAT_INT _PyInt_FormatAdvanced #define FORMAT_FLOAT _PyFloat_FormatAdvanced #include "../Objects/stringlib/formatter.h"
