[postgis-users] Crash when calling distance_ellipsoid with PostGIS1.0rc1
strk at refractions.net
strk at refractions.net
Mon Jan 24 10:03:07 PST 2005
Thanks for the report Stephen.
It was a bug in the definition of the function.
It is fixed in CVS.
Here is a quick patch:
--- lwgeom_spheroid.c 5 Jan 2005 12:44:47 -0000 1.6
+++ lwgeom_spheroid.c 24 Jan 2005 18:10:45 -0000
@@ -486,10 +486,10 @@
//distance (geometry,geometry, sphere)
// -geometrys MUST be points
-PG_FUNCTION_INFO_V1(distance_ellipsoid);
+PG_FUNCTION_INFO_V1(LWGEOM_distance_ellipsoid_point);
Datum LWGEOM_distance_ellipsoid_point(PG_FUNCTION_ARGS)
{
--strk;
On Mon, Jan 24, 2005 at 12:10:22PM -0500, Stephen Marshall wrote:
> 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
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list