Re: ogr2ogr with missing geometries crashes postgresql with segmentation fault

Paul Ramsey via postgis-users <[email protected]> Mon, 15 Dec 2025 09:15:22 -0800
Newsgroups gmane.comp.gis.postgis
Message-ID <CACowWR0YDja=-zhNuThDboD6i5OnbtGFM23Bxa4PzOBx1Oxjxw@mail.gmail.com>
--000000000000435643064600c2a3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I have started a ticket, and have a fix in hand.

https://trac.osgeo.org/postgis/ticket/6028

On Sat, Dec 13, 2025 at 6:28=E2=80=AFPM Paul Ramsey <pramsey@cleverelephant=
.ca>
wrote:

> First, thank you for a perfect minimal reproducer right up front. Very
> helpful and I have confirmed a crash here too. I haven=E2=80=99t put it i=
nto the
> debugger yet. Your empty polygon is pretty cool (as polygons tend to be)
> since it is not a classic =E2=80=9Cpolygon with no rings=E2=80=9D empty p=
olygon, it is a
> =E2=80=9Cpolygon with one ring that has no points=E2=80=9D empty polygon.
>
>   01 // LITTLE ENDIAN.
>   03000020 // POLYGON, WITH SRID
>   97130000 // SRID 5015
>   01000000 // ONE RING
>   00000000 // ZERO POINTS
>
> Why that causes a crash in the index code (or perhaps the bounding box
> extraction code) is yet to be determined.
> Anyways, very exciting to have a crasher, quite a rare defect these days.
> ATB,
> P.
>
>
> On Dec 12, 2025, at 5:19=E2=80=AFPM, Jorge Gustavo Rocha <[email protected]=
t> wrote:
>
> TL;DR
>
> A GIST index on a EMPTY POLYGON (encoded by GDAL) crashes postgresql with
> segmentation fault.
>
> drop table if exists fault;
> create table fault (fid integer, geom geometry(Polygon,5015));
> INSERT INTO fault (fid, geom) VALUES (1,
> '0103000020971300000100000000000000'::GEOMETRY);
> CREATE INDEX fault_geom_index ON fault USING GIST (geom);
>
>
>

--000000000000435643064600c2a3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have started a ticket, and have a fix in hand.<div><br><=
/div><div><a href=3D"https://trac.osgeo.org/postgis/ticket/6028">https://tr=
ac.osgeo.org/postgis/ticket/6028</a><br></div></div><br><div class=3D"gmail=
_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Sat,=
 Dec 13, 2025 at 6:28=E2=80=AFPM Paul Ramsey &lt;<a href=3D"mailto:pramsey@=
cleverelephant.ca">[email protected]</a>&gt; wrote:<br></div><block=
quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-w=
idth:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding=
-left:1ex"><div style=3D"line-break:after-white-space">First, thank you for=
 a perfect minimal reproducer right up front. Very helpful and I have confi=
rmed a crash here too. I haven=E2=80=99t put it into the debugger yet. Your=
 empty polygon is pretty cool (as polygons tend to be) since it is not a cl=
assic =E2=80=9Cpolygon with no rings=E2=80=9D empty polygon, it is a =E2=80=
=9Cpolygon with one ring that has no points=E2=80=9D empty polygon.<div><br=
></div><div><div>=C2=A0 01 // LITTLE ENDIAN.=C2=A0</div><div>=C2=A0 0300002=
0 // POLYGON, WITH SRID</div><div>=C2=A0 97130000 // SRID 5015</div><div>=
=C2=A0 01000000 // ONE RING</div><div>=C2=A0 00000000 // ZERO POINTS</div><=
div><br></div><div>Why that causes a crash in the index code (or perhaps th=
e bounding box extraction code) is yet to be determined.=C2=A0</div><div>An=
yways, very exciting to have a crasher, quite a rare defect these days.</di=
v><div>ATB,</div><div>P.</div><div><br></div><div><br><blockquote type=3D"c=
ite"><div>On Dec 12, 2025, at 5:19=E2=80=AFPM, Jorge Gustavo Rocha &lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>&gt; =
wrote:</div><br><div><span style=3D"font-family:HelveticaNeue;font-size:13p=
x;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing=
:normal;text-align:start;text-indent:0px;text-transform:none;white-space:no=
rmal;word-spacing:0px;text-decoration:none;float:none;display:inline">TL;DR=
</span><br style=3D"font-family:HelveticaNeue;font-size:13px;font-style:nor=
mal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-ali=
gn:start;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:0px;text-decoration:none"><br style=3D"font-family:HelveticaNeue;font-siz=
e:13px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-sp=
acing:normal;text-align:start;text-indent:0px;text-transform:none;white-spa=
ce:normal;word-spacing:0px;text-decoration:none"><span style=3D"font-family=
:HelveticaNeue;font-size:13px;font-style:normal;font-variant-caps:normal;fo=
nt-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-t=
ransform:none;white-space:normal;word-spacing:0px;text-decoration:none;floa=
t:none;display:inline">A GIST index on a EMPTY POLYGON (encoded by GDAL) cr=
ashes postgresql with segmentation fault.</span><br style=3D"font-family:He=
lveticaNeue;font-size:13px;font-style:normal;font-variant-caps:normal;font-=
weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tran=
sform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br st=
yle=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal;font-vari=
ant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text=
-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-de=
coration:none"><span style=3D"font-family:HelveticaNeue;font-size:13px;font=
-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:norma=
l;text-align:start;text-indent:0px;text-transform:none;white-space:normal;w=
ord-spacing:0px;text-decoration:none;float:none;display:inline">drop table =
if exists fault;</span><br style=3D"font-family:HelveticaNeue;font-size:13p=
x;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing=
:normal;text-align:start;text-indent:0px;text-transform:none;white-space:no=
rmal;word-spacing:0px;text-decoration:none"><span style=3D"font-family:Helv=
eticaNeue;font-size:13px;font-style:normal;font-variant-caps:normal;font-we=
ight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transf=
orm:none;white-space:normal;word-spacing:0px;text-decoration:none;float:non=
e;display:inline">create table fault (fid integer, geom geometry(Polygon,50=
15));</span><br style=3D"font-family:HelveticaNeue;font-size:13px;font-styl=
e:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;tex=
t-align:start;text-indent:0px;text-transform:none;white-space:normal;word-s=
pacing:0px;text-decoration:none"><span style=3D"font-family:HelveticaNeue;f=
ont-size:13px;font-style:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;text-decoration:none;float:none;display:i=
nline">INSERT INTO fault (fid, geom) VALUES (1, &#39;0103000020971300000100=
000000000000&#39;::GEOMETRY);</span><br style=3D"font-family:HelveticaNeue;=
font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:400;l=
etter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;w=
hite-space:normal;word-spacing:0px;text-decoration:none"><span style=3D"fon=
t-family:HelveticaNeue;font-size:13px;font-style:normal;font-variant-caps:n=
ormal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0p=
x;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:n=
one;float:none;display:inline">CREATE INDEX fault_geom_index ON fault USING=
 GIST (geom);</span><br style=3D"font-family:HelveticaNeue;font-size:13px;f=
ont-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:no=
rmal;text-align:start;text-indent:0px;text-transform:none;white-space:norma=
l;word-spacing:0px;text-decoration:none"></div></blockquote></div><br></div=
></div></blockquote></div>

--000000000000435643064600c2a3--