[postgis-tickets] [PostGIS] #4919: SQL reliably crashes Server

PostGIS trac at osgeo.org
Tue May 18 07:38:03 PDT 2021


#4919: SQL reliably crashes Server
---------------------+---------------------------
 Reporter:  Robins   |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 3.1.2
Component:  postgis  |    Version:  3.0.x
 Keywords:           |
---------------------+---------------------------
 This was a (very) large SQL that I tried my best to cut down but couldn't
 beyond what is given below.

 This SQL crashes reliably on Postgres v13.3 and PostGIS v3.0.3 (for me). I
 was going to post this to Postgres hackers list, when I saw that the top
 end of the backtrace was mostly PostGIS functions and then thought I'd
 post this here instead (and that the SQL is apparently doing overlaps on
 geography type).

 (Feel free to rename the Issue title, since I couldn't find a better name)

 **SQL**
 {{{

 SELECT 1
 FROM (SELECT NULL::int a LIMIT 0) AS ref_0
 WHERE CASE
     WHEN CASE
         WHEN pg_catalog.jsonb_build_array() ? version()
           THEN cast(NULL AS point)
         ELSE cast(NULL AS point)
         END @(SELECT NULL::lseg LIMIT 0)
       THEN cast(NULL AS GEOGRAPHY)
     END && CASE
     WHEN (
         CASE
           WHEN ref_0.a IS NULL
           THEN cast(NULL AS float4)
           ELSE cast(NULL AS float4)
         END <= (
           SELECT NULL::real LIMIT 0
           )
         )
       THEN NULL::GEOGRAPHY
     END
         limit 58;

 }}}


 **Backtrace**
 {{{
 #0  detoast_attr_slice (attr=attr at entry=0x0,
 sliceoffset=sliceoffset at entry=0, slicelength=slicelength at entry=40) at
 detoast.c:226
 #1  0x00000000008a3b55 in pg_detoast_datum_slice (datum=datum at entry=0x0,
 first=first at entry=0, count=count at entry=40) at fmgr.c:1754
 #2  0x000014e217f4f793 in gserialized_datum_get_gidx_p
 (gsdatum=gsdatum at entry=0, gidx=gidx at entry=0x7fffb1ba7730) at
 gserialized_gist.c:185
 #3  0x000014e217f4faa9 in gserialized_datum_get_gbox_p (gsdatum=0,
 gbox=gbox at entry=0x7fffb1ba77d0) at gserialized_gist.c:157
 #4  0x000014e217ef971b in gserialized_sel_internal (root=<optimized out>,
 args=<optimized out>, varRelid=<optimized out>, mode=0) at
 gserialized_estimate.c:2253
 #5  0x000014e217ef9799 in gserialized_gist_sel
 (fcinfo=fcinfo at entry=0x7fffb1ba7850) at gserialized_estimate.c:2281
 #6  0x00000000008a24f4 in DirectFunctionCall5Coll
 (func=func at entry=0x14e217ef9780 <gserialized_gist_sel>,
 collation=collation at entry=0, arg1=<optimized out>,
     arg2=<optimized out>, arg3=<optimized out>, arg4=<optimized out>,
 arg5=0) at fmgr.c:908
 #7  0x000014e217ef96a4 in gserialized_gist_sel_nd (fcinfo=<optimized out>)
 at gserialized_estimate.c:2204
 #8  0x00000000008a2c6e in FunctionCall4Coll (flinfo=0x7fffb1ba7970,
 collation=<optimized out>, arg1=<optimized out>, arg2=<optimized out>,
 arg3=<optimized out>,
     arg4=<optimized out>) at fmgr.c:1216
 #9  0x00000000008a3247 in OidFunctionCall4Coll (functionId=<optimized
 out>, collation=collation at entry=0, arg1=arg1 at entry=49189016,
 arg2=arg2 at entry=1118028,
     arg3=arg3 at entry=50164232, arg4=arg4 at entry=0) at fmgr.c:1452
 #10 0x000000000070b45d in restriction_selectivity
 (root=root at entry=0x2ee9098, operatorid=1118028, args=0x2fd7208,
 inputcollid=0, varRelid=varRelid at entry=0)
     at plancat.c:1785
 .
 .
 .

 }}}


 {{{
 $ psql
 psql (13beta2, server 13.3)
 Type "help" for help.

 r=> \dx postgis
                                    List of installed extensions
   Name   | Version | Schema |                             Description
 ---------+---------+--------+---------------------------------------------------------------------
  postgis | 3.0.3   | public | PostGIS geometry, geography, and raster
 spatial types and functions
 (1 row)

 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4919>
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-tickets mailing list