Mercurial > cpython-lru_cache-weakref
view Python/pystrcmp.c @ 44832:eb2eafda29b7 legacy-trunk
Provide a sanity check during PyThreadState_DeleteCurrent() and
PyThreadState_Delete() to avoid an infinite loop when the tstate list
is messed up and has somehow becomes circular and does not contain the
current 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.
Attaching to a process where its happening: it has always been in an
infinite loop over a single element tstate list that is not the tstate
we're looking to delete. It has been in t_bootstrap()'s call to
PyThreadState_DeleteCurrent() as a pthread is exiting.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 21 Jan 2008 07:11:11 +0000 |
| parents | 4dc01402d78a |
| children | 0a485593ae1c |
line wrap: on
line source
/* Cross platform case insenstive string compare functions */ #include "Python.h" int PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size) { if (size == 0) return 0; while ((--size > 0) && (tolower(*s1) == tolower(*s2))) { if (!*s1++ || !*s2++) break; } return tolower(*s1) - tolower(*s2); } int PyOS_mystricmp(const char *s1, const char *s2) { while (*s1 && (tolower(*s1++) == tolower(*s2++))) { ; } return (tolower(*s1) - tolower(*s2)); }
