[geos-devel] GEOS, Shapely, DLLs, and memory

Charlie Savage cfis at savagexi.com
Mon Apr 27 15:44:02 EDT 2009


Hi Aron,

> From what we can tell our application was crashing
> because memory that was being allocated in the GEOS dll was being
> released inside of our application. When converting a GEOS geometry
> object to a string, Shapely calls GEOSGeomToWKT_r which creates a char
> buffer using std::malloc. After the call Shapely releases the memory
> using the standard free function. According to a "Potential Errors
> Passing CRT Objects Across DLL Boundaries" [1]:

Yup, you can't do that.  The GEOS api has to provide a way of freeing 
the buffer (just like your patch adds).

> I have attached a patch for both GEOS and Shapely that we have been
> testing with for a few weeks without any problems. Does anyone have a
> better way to address this issue?

If you build Shapely (and Geos) using VC++ in Debug mode with assertions 
on (-RTC1 off the top of my head), then VC will raise assertions errors 
on problems like this.  Its a lot easier to find them that way.

Charlie
-- 
Charlie Savage
http://cfis.savagexi.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.osgeo.org/pipermail/geos-devel/attachments/20090427/8a98f6d6/smime.bin


More information about the geos-devel mailing list