[postgis-tickets] [PostGIS] #5241: ST_SnapToGrid crashes on multipolygon with an empty polygon

PostGIS trac at osgeo.org
Thu Oct 27 16:00:43 PDT 2022


#5241: ST_SnapToGrid crashes on multipolygon with an empty polygon
----------------------+---------------------------
  Reporter:  robe     |      Owner:  robe
      Type:  defect   |     Status:  new
  Priority:  blocker  |  Milestone:  PostGIS 3.0.8
 Component:  postgis  |    Version:  3.2.x
Resolution:           |   Keywords:
----------------------+---------------------------
Comment (by robe):

 GDB shows the issue is here.


 {{{
 ptarray_grid_in_place (pa=0x7f7f7f7f7f7f7f7e, grid=0x4d1e7c0)
     at ptarray.c:2076
 2076            uint32_t ndims = FLAGS_NDIMS(pa->flags);
 (gdb) bt
 #0  ptarray_grid_in_place (pa=0x7f7f7f7f7f7f7f7e, grid=0x4d1e7c0)
     at ptarray.c:2076
 #1  0x0000000000000000 in ?? ()
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)
 (gdb)

 }}}


 Which is a surprise to me.  I can't figure out why it crashes there.

 If in the lwgeom_grid_in_place function I add a line


 {{{
 if (lwgeom_is_empty(geom)) return;
 }}}


 It regresses and doesn't crash anymore, and returns expected answer,
 though I need to test with a smaller grid to confirm.

 But I don't know how to protect the ultimate root cause and if that root
 cause could be hole for other things.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5241#comment:2>
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