[postgis-users] GEOS crashing PostgreSQL?

Michael Fuhr mike at fuhr.org
Tue Oct 24 20:53:09 PDT 2006


On Tue, Oct 24, 2006 at 04:42:11PM -0700, Tyler Mitchell wrote:
> So I guess there is something going on in 1.1.5 and SVN version that
> is a problem for me.  

I built SVN on Solaris 9/sparc 64-bit and got regression failures for
regress_ogc and regress_bdpoly due to segmentation faults in the
backend.  I looked through the build output and noticed "incompatible
pointer type" compiler warnings for lwgeom_geos_c.c.  I saw that
ptarray_from_GEOSCoordSeq() was passing a size_t * as the second
argument to GEOSCoordSeq_getSize() and GEOSCoordSeq_getDimensions(),
but those functions expect unsigned int *.  On my 64-bit platform
size_t and unsigned int have different sizes (64 bits and 32 bits,
respectively), which I suspected was causing problems.  After I
applied the attached patch all regression tests passed.

-- 
Michael Fuhr
-------------- next part --------------
Index: lwgeom/lwgeom_geos_c.c
===================================================================
--- lwgeom/lwgeom_geos_c.c	(revision 2515)
+++ lwgeom/lwgeom_geos_c.c	(working copy)
@@ -2240,8 +2240,8 @@
 POINTARRAY *
 ptarray_from_GEOSCoordSeq(GEOSCoordSeq cs, char want3d)
 {
-	size_t dims=2;
-	size_t size;
+	unsigned int dims=2;
+	unsigned int size;
 	unsigned int i, ptsize;
 	uchar *points, *ptr;
 	POINTARRAY *ret;
@@ -2254,7 +2254,7 @@
 			lwerror("Exception thrown");
 
 #ifdef PGIS_DEBUG_GEOS2POSTGIS 
-	lwnotice(" GEOSCoordSeq size: %d", size);
+	lwnotice(" GEOSCoordSeq size: %u", size);
 #endif
 
 	if ( want3d )
@@ -2262,14 +2262,14 @@
 		if ( ! GEOSCoordSeq_getDimensions(cs, &dims) )
 			lwerror("Exception thrown");
 #ifdef PGIS_DEBUG_GEOS2POSTGIS 
-		lwnotice(" GEOSCoordSeq dimensions: %d", dims);
+		lwnotice(" GEOSCoordSeq dimensions: %u", dims);
 #endif
 		/* forget higher dimensions (if any) */
 		if ( dims > 3 ) dims = 3;
 	}
 
 #ifdef PGIS_DEBUG_GEOS2POSTGIS 
-	lwnotice(" output dimensions: %d", dims);
+	lwnotice(" output dimensions: %u", dims);
 #endif
 
 	ptsize = sizeof(double)*dims;


More information about the postgis-users mailing list