[Pythonmac-SIG] malloc error with imaplib or socket on OS X

Chris Miles chris_py006 at psychofx.com
Tue Mar 1 15:01:29 CET 2005


Hi, I have recently come across what looks like a serious bug with  
Python on OS X.  While writing a program using imaplib to connect to  
some IMAP4 servers I encountered a MemoryError exception with a  
malloc() error which was easily reproducible with my data at the time.   
The malloc error was:

*** malloc: vm_allocate(size=9252864) failed (error code=3)
*** malloc[1522]: error: Can't allocate region

A thread on comp.lang.python shows that this bug has been encountered  
by others as well.
    
http://groups-beta.google.com/group/comp.lang.python/browse_thread/ 
thread/cd5a8f28b021c269/cf7e574e3bc566df

I tested my program on my standard OS X 10.3 Python (2.3) as well as a  
build of 2.4 and found the same MemoryError.  (btw: I had plenty of  
free RAM at the time.  Over 1/4 of 1GB on a powerbook G4)

I tested the exact same program connecting to the exact same IMAP4  
server (Exchange actually) on a Linux box and it worked fine (actually  
a Linux host running in VPC on the very same Mac).

The data that was causing the MemoryError was a 9 MB mail message on  
the IMAP server.  After I deleted this message the program on the Mac  
ran fine.  The other messages were max 1 MB in size and there were  
about 114 of them.  (The program downloads every message from a user's  
IMAP account, amongst other things.)

Attached is a full Traceback of the MemoryError (as formatted by  
iPython).

Is this a known issue, or should I submit it somewhere?

Cheers,
Chris

-- 
Chris Miles
http://chrismiles.info/
-------------- next part --------------
*** malloc: vm_allocate(size=9244672) failed (error code=3)
*** malloc[1436]: error: Can't allocate region
---------------------------------------------------------------------------
exceptions.MemoryError                               Traceback (most recent call last)

/Users/chris/<console> 

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in fetch(self, message_set, message_parts)
    415         """
    416         name = 'FETCH'
--> 417         typ, dat = self._simple_command(name, message_set, message_parts)
    418         return self._untagged_response(typ, dat, name)
    419 

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in _simple_command(self, name, *args)
    998     def _simple_command(self, name, *args):
    999 
-> 1000         return self._command_complete(name, self._command(name, *args))
   1001 
   1002 

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in _command_complete(self, name, tag)
    832             raise self.abort('command: %s => %s' % (name, val))
    833         except self.error, val:
--> 834             raise self.error('command: %s => %s' % (name, val))
    835         self._check_bye()
    836         if typ == 'BAD':

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in _get_tagged_response(self, tag)
    934                     if self.debug >= 1:
    935                         self.print_log()
--> 936                 raise
    937 
    938 

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in _get_response(self)
    891                     if self.debug >= 4:
    892                         self._mesg('read literal size %s' % size)
--> 893                 data = self.read(size)
    894 
    895                 # Store response with literal as tuple

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py in read(self, size)    229     def read(self, size):
    230         """Read 'size' bytes from remote."""
--> 231         return self.file.read(size)
    232 
    233 

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/socket.py in read(self, size)
    299                 left = size - buf_len
    300                 recv_size = max(self._rbufsize, left)
--> 301                 data = self._sock.recv(recv_size)
    302                 if not data:
    303                     break

MemoryError: 


More information about the Pythonmac-SIG mailing list