[issue11277] Crash with mmap and sparse files on Mac OS X

Steffen Daode Nurpmeso report at bugs.python.org
Wed May 4 15:48:13 CEST 2011


Steffen Daode Nurpmeso <sdaoden at googlemail.com> added the comment:

> error: [Errno 12] Cannot allocate memory

@haypo: Well i told you i have no idea.  These bots are 32 bit?

I'll attach 11277-27.3.diff which does @skipUnless(not 32 bit).
Note i'll test against >_4G - does this work (on 32 bit and in
Python)?  A pity that Python does not offer a 'condition is
always true due to datatype storage restriction' check?!

And i don't think it makes sense to test a _1GB mmap on 32 bit at
all (but at least address space shouldn't exhaust for that).
So, sorry, also for the two bugs in that two-liner, but very
especially the 'm' case.

----------
Added file: http://bugs.python.org/file21885/11277-27.3.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11277>
_______________________________________
-------------- next part --------------
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -2,7 +2,7 @@
 from test.test_support import TESTFN, run_unittest, import_module, unlink, requires
 import binascii
 import random
-from test.test_support import precisionbigmemtest, _1G
+from test.test_support import precisionbigmemtest, _1G, _2G, _4G
 import sys
 
 try:
@@ -75,17 +75,16 @@
 # Issue #11277 - check that inputs of 2 GB are handled correctly.
 # Be aware of issues #1202, #8650, #8651 and #10276
 class ChecksumBigBufferTestCase(unittest.TestCase):
-    int_max = 0x7FFFFFFF
-
+    @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.")
     @unittest.skipUnless(mmap, "mmap() is not available.")
     def test_big_buffer(self):
         if sys.platform[:3] == 'win' or sys.platform == 'darwin':
             requires('largefile',
                      'test requires %s bytes and a long time to run' %
-                     str(self.int_max))
+                     str(_2G -1))
         try:
             with open(TESTFN, "wb+") as f:
-                f.seek(self.int_max-4)
+                f.seek(_2G -1-4)
                 f.write("asdf")
                 f.flush()
                 m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)


More information about the Python-bugs-list mailing list