[postgis-users] Crash when calling distance_ellipsoid with PostGIS1.0rc1

Stephen Marshall smarshall at wsi.com
Mon Jan 24 09:10:22 PST 2005


Calling the distance_ellipsoid function fails with PostGIS1.0rc1, where 
is worked with PostGIS0.9.

In this example, the same call was made in two contexts, both using 
PostgreSQL 8.0.0; the first with PostGIS 0.9 and the second with 
PostGIS1.0rc1.  In the latter case, the postgres backend server terminated.

PostGIS 0.9:
avdata_orig# select distance_spheroid(geometryfromtext('POINT(-77.122778 
12.008611)', 4326), geometryfromtext('POINT(-89.656111 20.938056)', 
4326), 'SPHEROID["WGS_1984",6378137,298.257223563]]'::spheroid);
 distance_spheroid
-------------------
  1662043.58935675
(1 row)
 
PostGIS 1.0rc1:
avdata=# select distance_spheroid(geometryfromtext('POINT(-77.122778 
12.008611)', 4326), geometryfromtext('POINT(-89.656111 20.938056)', 
4326), 'SPHEROID["WGS_1984",6378137,298.257223563]]'::spheroid);
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

I tracked the crash into the PostGIS function 
LWGEOM_distance_ellipsoid_point().  It occurs at this call:

    PG_LWGEOM *geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));

By calling this function:

    DatumGetPointer(PG_GETARG_DATUM(0));

I was able to determine that a valid (non-zero) address is being 
returned for the Datum pointer, so I think the error occurs in the 
PG_DETOAST_DATUM call.

My suspicion is that the data is being incorrectly identified as a 
toasted value, and hence erroniously going through "detoasting" logic in 
the postgres function pg_detoast_datum (found in 
./src/backend/utils/fmgr/fmgr.c in the postgres distribution).  However, 
I have no inside knowledge of the postgres toasting code, so this is a 
fairly naive guess.

Thanks for any help you can give.
Steve Marshall






More information about the postgis-users mailing list