[Python-checkins] r42012 - in python/trunk: Lib/test/output/test_mmap Lib/test/test_mmap.py Misc/ACKS Misc/NEWS Modules/mmapmodule.c

neal.norwitz python-checkins at python.org
Wed Jan 11 09:54:49 CET 2006


Author: neal.norwitz
Date: Wed Jan 11 09:54:45 2006
New Revision: 42012

Modified:
   python/trunk/Lib/test/output/test_mmap
   python/trunk/Lib/test/test_mmap.py
   python/trunk/Misc/ACKS
   python/trunk/Misc/NEWS
   python/trunk/Modules/mmapmodule.c
Log:
Fix SF bug #1402308, segfault when using mmap(-1, ...)

This didn't crash on Linux, but valgrind complained.
I'm not sure if this test is valid on Windows.

Will backport.


Modified: python/trunk/Lib/test/output/test_mmap
==============================================================================
--- python/trunk/Lib/test/output/test_mmap	(original)
+++ python/trunk/Lib/test/output/test_mmap	Wed Jan 11 09:54:45 2006
@@ -31,6 +31,7 @@
   Modifying copy-on-write memory map.
   Ensuring copy-on-write maps cannot be resized.
   Ensuring invalid access parameter raises exception.
+  Try opening a bad file descriptor...
   Ensuring that passing 0 as map length sets map size to current file size.
   Ensuring that passing 0 as map length sets map size to current file size.
  Test passed

Modified: python/trunk/Lib/test/test_mmap.py
==============================================================================
--- python/trunk/Lib/test/test_mmap.py	(original)
+++ python/trunk/Lib/test/test_mmap.py	Wed Jan 11 09:54:45 2006
@@ -281,6 +281,14 @@
         except OSError:
             pass
 
+    print '  Try opening a bad file descriptor...'
+    try:
+        mmap.mmap(-1, 4096)
+    except mmap.error:
+        pass
+    else:
+        verify(0, 'expected a mmap.error but did not get it')
+
     # Do a tougher .find() test.  SF bug 515943 pointed out that, in 2.2,
     # searching for data with embedded \0 bytes didn't work.
     f = open(TESTFN, 'w+')

Modified: python/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS	(original)
+++ python/trunk/Misc/ACKS	Wed Jan 11 09:54:45 2006
@@ -529,6 +529,7 @@
 Neil Schemenauer
 David Scherer
 Gregor Schmid
+Ralf Schmitt
 Peter Schneider-Kamp
 Sam Schulenburg
 Stefan Schwarzer

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Jan 11 09:54:45 2006
@@ -216,6 +216,8 @@
 Extension Modules
 -----------------
 
+- Bug #1402308, (possible) segfault when using mmap.mmap(-1, ...)
+
 - Bug #1400822, _curses over{lay,write} doesn't work when passing 6 ints.
   Also fix ungetmouse() which did not accept arguments properly.
   The code now conforms to the documented signature.

Modified: python/trunk/Modules/mmapmodule.c
==============================================================================
--- python/trunk/Modules/mmapmodule.c	(original)
+++ python/trunk/Modules/mmapmodule.c	Wed Jan 11 09:54:45 2006
@@ -918,6 +918,7 @@
 #endif
 	m_obj = PyObject_New (mmap_object, &mmap_object_type);
 	if (m_obj == NULL) {return NULL;}
+	m_obj->data = NULL;
 	m_obj->size = (size_t) map_size;
 	m_obj->pos = (size_t) 0;
 	m_obj->fd = dup(fd);


More information about the Python-checkins mailing list