[postgis-devel] [PostGIS] #1951: Crash in ST_Distance

PostGIS trac at osgeo.org
Wed Aug 15 02:40:30 PDT 2012


#1951: Crash in ST_Distance
---------------------------+------------------------------------------------
 Reporter:  realityexists  |       Owner:  pramsey      
     Type:  defect         |      Status:  new          
 Priority:  medium         |   Milestone:  PostGIS 2.1.0
Component:  postgis        |     Version:  trunk        
 Keywords:                 |  
---------------------------+------------------------------------------------
 When I run a particular plpgsql function that calls ST_Distance the
 PostgreSQL backend crashes:
 {{{
 Program received signal SIGSEGV, Segmentation fault.
 sphere_distance (s=0x9b4cea8, e=0x0) at lwgeodetic.c:758
 758             double d_lon = e->lon - s->lon;
 }}}
 The following simplified function reproduces the crash:
 {{{
 CREATE OR REPLACE FUNCTION _distance_crash_repro6()
 RETURNS integer AS
 $BODY$
 DECLARE
         line geography[];
         i integer;
         current_line geography(LineString);
         current_distance float;
 BEGIN
         line := ARRAY[
                 'POINT(-60.1529782532063 -3.00395030900105)'::geography,
                 'POINT(-60.1529985502867 -3.00511933469609)'::geography,
                 'POINT(-60.1529985502867 -3.00511933469609)'::geography];

         FOR i IN array_lower(line, 1) .. array_upper(line, 1) - 1 LOOP
                 current_line := ST_MakeLine(line[i]::geometry, line[i +
 1]::geometry)::geography;
                 current_distance := ST_Distance(current_line,
 'POINT(-60.1529903235046 -3.00464549022075)'::geography);
         END LOOP;

         RETURN -1;
 END
 $BODY$ LANGUAGE plpgsql IMMUTABLE;

 SELECT _distance_crash_repro6();
 }}}

 I haven't been able to repro it without a function or without an array.
 Stack trace from the simplified repro attached.

 "POSTGIS="2.1.0SVN r10181" GEOS="3.4.0dev-CAPI-1.8.0 r3703" PROJ="Rel.
 4.8.0, 6 March 2012" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8"
 RASTER"

 "PostgreSQL 9.1.4 on i686-pc-linux-gnu, compiled by gcc (Ubuntu/Linaro
 4.5.2-8ubuntu4) 4.5.2, 32-bit"

 (also happens on Windows 7 x64)

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1951>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list