[Python-checkins] r69550 - in python/branches/release30-maint: Lib/test/test_multiprocessing.py Misc/NEWS Modules/_multiprocessing/connection.h Modules/_multiprocessing/pipe_connection.c Modules/_multiprocessing/socket_connection.c

jesse.noller python-checkins at python.org
Thu Feb 12 20:44:59 CET 2009


Author: jesse.noller
Date: Thu Feb 12 20:44:58 2009
New Revision: 69550

Log:
Merge 68778,68788 to maint

Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Lib/test/test_multiprocessing.py
   python/branches/release30-maint/Misc/NEWS
   python/branches/release30-maint/Modules/_multiprocessing/connection.h
   python/branches/release30-maint/Modules/_multiprocessing/pipe_connection.c
   python/branches/release30-maint/Modules/_multiprocessing/socket_connection.c

Modified: python/branches/release30-maint/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_multiprocessing.py	(original)
+++ python/branches/release30-maint/Lib/test/test_multiprocessing.py	Thu Feb 12 20:44:58 2009
@@ -62,6 +62,8 @@
 HAVE_GETVALUE = not getattr(_multiprocessing,
                             'HAVE_BROKEN_SEM_GETVALUE', False)
 
+WIN32 = (sys.platform == "win32")
+
 #
 # Creates a wrapper for a function which records the time it takes to finish
 #
@@ -1683,6 +1685,18 @@
         logger.setLevel(level=LOG_LEVEL)
 
 #
+# Test to verify handle verification, see issue 3321
+#
+
+class TestInvalidHandle(unittest.TestCase):
+
+    def test_invalid_handles(self):
+        if WIN32:
+            return
+        conn = _multiprocessing.Connection(44977608)
+        self.assertRaises(IOError, conn.poll)
+        self.assertRaises(IOError, _multiprocessing.Connection, -1)
+#
 # Functions used to create test cases from the base ones in this module
 #
 
@@ -1786,7 +1800,7 @@
                           multiprocessing.connection.answer_challenge,
                           _FakeConnection(), b'abc')
 
-testcases_other = [OtherTest]
+testcases_other = [OtherTest, TestInvalidHandle]
 
 #
 #

Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Thu Feb 12 20:44:58 2009
@@ -129,6 +129,13 @@
 - Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored
   under NT and OS2. Patch by Philip Jenvey.
 
+- Issue #3321: _multiprocessing.Connection() doesn't check handle; added checks
+  for *nix machines for negative handles and large int handles. Without this check
+  it is possible to segfault the interpreter.
+
+- Issue #4449: AssertionError in mp_benchmarks.py, caused by an underlying issue
+  in sharedctypes.py.
+
 - Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
 
 - Partial fix to issue #1731706: memory leak in Tkapp_Call when calling

Modified: python/branches/release30-maint/Modules/_multiprocessing/connection.h
==============================================================================
--- python/branches/release30-maint/Modules/_multiprocessing/connection.h	(original)
+++ python/branches/release30-maint/Modules/_multiprocessing/connection.h	Thu Feb 12 20:44:58 2009
@@ -362,7 +362,7 @@
 	}
 
 	Py_BEGIN_ALLOW_THREADS
-	res = conn_poll(self, timeout);
+	res = conn_poll(self, timeout, _save);
 	Py_END_ALLOW_THREADS
 
 	switch (res) {

Modified: python/branches/release30-maint/Modules/_multiprocessing/pipe_connection.c
==============================================================================
--- python/branches/release30-maint/Modules/_multiprocessing/pipe_connection.c	(original)
+++ python/branches/release30-maint/Modules/_multiprocessing/pipe_connection.c	Thu Feb 12 20:44:58 2009
@@ -83,10 +83,8 @@
  * Check whether any data is available for reading
  */
 
-#define conn_poll(conn, timeout) conn_poll_save(conn, timeout, _save)
-
 static int
-conn_poll_save(ConnectionObject *conn, double timeout, PyThreadState *_save)
+conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save)
 {
 	DWORD bytes, deadline, delay;
 	int difference, res;

Modified: python/branches/release30-maint/Modules/_multiprocessing/socket_connection.c
==============================================================================
--- python/branches/release30-maint/Modules/_multiprocessing/socket_connection.c	(original)
+++ python/branches/release30-maint/Modules/_multiprocessing/socket_connection.c	Thu Feb 12 20:44:58 2009
@@ -153,11 +153,23 @@
  */
 
 static int
-conn_poll(ConnectionObject *conn, double timeout)
+conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save)
 {
 	int res;
 	fd_set rfds;
 
+	/*
+	 * Verify the handle, issue 3321. Not required for windows.
+	 */ 
+	#ifndef MS_WINDOWS
+		if (((int)conn->handle) < 0 || ((int)conn->handle) >= FD_SETSIZE) {
+			Py_BLOCK_THREADS
+			PyErr_SetString(PyExc_IOError, "handle out of range in select()");
+			Py_UNBLOCK_THREADS
+			return MP_EXCEPTION_HAS_BEEN_SET;
+		}
+	#endif
+
 	FD_ZERO(&rfds);
 	FD_SET((SOCKET)conn->handle, &rfds);
 


More information about the Python-checkins mailing list