[Python-checkins] cpython (merge 3.3 -> default): #19227: merge with 3.3
georg.brandl
python-checkins at python.org
Sun Oct 27 07:56:49 CET 2013
http://hg.python.org/cpython/rev/d3a13a7be9e9
changeset: 86683:d3a13a7be9e9
parent: 86681:ab0c133288f8
parent: 86682:021ca321b26e
user: Georg Brandl <georg at python.org>
date: Sun Oct 27 07:57:42 2013 +0100
summary:
#19227: merge with 3.3
files:
Misc/NEWS | 3 +++
Modules/_ssl.c | 15 ++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,9 @@
- Issue #19329: Optimized compiling charsets in regular expressions.
+- Issue #19227: Try to fix deadlocks caused by re-seeding then OpenSSL
+ pseudo-random number generator on fork().
+
- Issue #16037: HTTPMessage.readheaders() raises an HTTPException when more than
100 headers are read. Adapted from patch by Jyrki Pulliainen.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -2952,7 +2952,7 @@
/* Seed OpenSSL's PRNG at fork(), http://bugs.python.org/issue18747
*
- * The parent handler seeds the PRNG from pseudo-random data like pid, the
+ * The prepare handler seeds the PRNG from pseudo-random data like pid, the
* current time (miliseconds or seconds) and an uninitialized array.
* The array contains stack variables that are impossible to predict
* on most systems, e.g. function return address (subject to ASLR), the
@@ -2961,16 +2961,17 @@
*
* Note:
* The code uses pthread_atfork() until Python has a proper atfork API. The
- * handlers are not removed from the child process. A parent handler is used
+ * handlers are not removed from the child process. A prepare handler is used
* instead of a child handler because fork() is supposed to be async-signal
- * safe but the handler calls unsafe functions.
+ * safe but the handler calls unsafe functions. A parent handler has caused
+ * other problems, see issue #19227.
*/
#if defined(HAVE_PTHREAD_ATFORK) && defined(WITH_THREAD)
#define PYSSL_RAND_ATFORK 1
static void
-PySSL_RAND_atfork_parent(void)
+PySSL_RAND_atfork_prepare(void)
{
struct {
char stack[128]; /* uninitialized (!) stack data, 128 is an
@@ -2996,9 +2997,9 @@
if (registered)
return 0;
- retval = pthread_atfork(NULL, /* prepare */
- PySSL_RAND_atfork_parent, /* parent */
- NULL); /* child */
+ retval = pthread_atfork(PySSL_RAND_atfork_prepare, /* prepare */
+ NULL, /* parent */
+ NULL); /* child */
if (retval != 0) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list