[SciPy-user] malloc incorrect checksum for freed object error using delaunay module

Robert Kern robert.kern at gmail.com
Thu Sep 28 20:24:30 CDT 2006

Aaron Hoover wrote:
> Hi all,
> I'm using SciPy 0.5.1 with the delaunay module built from source on  
> OS X (Intel Mac). I'm also using iPython 0.7.2, NumPy 1.0.5b, and  
> matplotlib 0.87.5 (all built from source).
> I'm having the strangest problem - I've been able to use the delaunay  
> function in delaunay.triangulate just fine up until recently when I  
> triangulated a fairly large data set (2M points).
> The triangulation succeeded (but took a while, of course), but now  
> whenever I attempt to use the delaunay function again, I get the  
> following error:
> Python(288,0xa000cf60) malloc: *** error for object 0x1b47e00:  
> incorrect checksum for freed object - object was probably modified  
> after being freed, break at szone_error to debug
> Python(288,0xa000cf60) malloc: *** set a breakpoint in szone_error to  
> debug
> Then, iPython dies with a "Bus error." Rebooting does not help
> My question is twofold. Does anyone know what causes this error?  
> (Google turned up an enormous variety of sources for this error in  
> just about all software that uses malloc.h).

I'll look into it. The Delaunay triangulation code is a great big ball of mud 
when it comes to memory handling. The core algorithm derives from an old C 
codebase that semi-manually manages a memory pool acquired using malloc. This is 
wrapped in some C++ upon which I added my own C++ from before I was terribly 
comfortable with the C++ and STL memory models. On top of *that*, there is the 
Python memory management. Fun.

Please attach the script (or preferably, a minimal example that demonstrates the 
problem) to a ticket on the Trac, I would appreciate it. Due to spam, I'm afraid 
you will have to register an account.


After that:


The button to attach a file will show up after you initially create the ticket.

I might not be able to reproduce your problem on the machines available to me 
(PPC OS X and AMD64 Linux), so you might want to follow the advice of the error 
message that you got and run your program under the gdb debugger. Something like 
the following should work:

[~]$ gdb python
GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...Reading symbols for shared 
libraries ... done

(gdb) break szone_error
Breakpoint 1 at 0x901143c4
(gdb) run my_script.py

> And, is it possible to fix this without rebuilding SciPy. Rebuilding  
> isn't really *that* big of a deal, but I'd like to know if there's an  
> easier solution in case this thing rears its ugly head in the
> future.

You won't be able to get around rebuilding the _delaunay extension module, but 
the rest of scipy you can leave alone.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the SciPy-user mailing list