Re: ogr2ogr with missing geometries crashes postgresql with segmentation fault

Paul Ramsey via postgis-users <[email protected]> Mon, 15 Dec 2025 16:35:33 -0800
Newsgroups gmane.comp.gis.postgis
Message-ID <CACowWR2s40YuLnUJNM4u5-xFxMEcjguUdC3iLOW8XZ7vWTMNFQ@mail.gmail.com>
--0000000000007635c3064606e872
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Should be fixed in all stable branches and going forward.

On Mon, Dec 15, 2025 at 9:15=E2=80=AFAM Paul Ramsey <pramsey@cleverelephant=
.ca>
wrote:

> 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@cleverelepha=
nt.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 =
into 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 =
polygon, 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].=
pt>
>> wrote:
>>
>> TL;DR
>>
>> A GIST index on a EMPTY POLYGON (encoded by GDAL) crashes postgresql wit=
h
>> 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);
>>
>>
>>

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

<div dir=3D"ltr"><div>Should be fixed in all stable branches and going forw=
ard.</div><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"=
ltr" class=3D"gmail_attr">On Mon, Dec 15, 2025 at 9:15=E2=80=AFAM Paul Rams=
ey &lt;<a href=3D"mailto:[email protected]">pramsey@cleverelephant.=
ca</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-le=
ft-color:rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">I have started=
 a ticket, and have a fix in hand.<div><br></div><div><a href=3D"https://tr=
ac.osgeo.org/postgis/ticket/6028" target=3D"_blank">https://trac.osgeo.org/=
postgis/ticket/6028</a><br></div></div><br><div class=3D"gmail_quote"><div =
dir=3D"ltr" class=3D"gmail_attr">On Sat, Dec 13, 2025 at 6:28=E2=80=AFPM Pa=
ul Ramsey &lt;<a href=3D"mailto:[email protected]" target=3D"_blank=
">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-l=
eft-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div s=
tyle=3D"line-break:after-white-space">First, thank you for a perfect minima=
l reproducer right up front. Very helpful and I have confirmed 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 classic =E2=80=9Cpo=
lygon with no rings=E2=80=9D empty polygon, it is a =E2=80=9Cpolygon with o=
ne 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 03000020 // POLYGON, WIT=
H 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 the bounding box extr=
action code) is yet to be determined.=C2=A0</div><div>Anyways, very excitin=
g to have a crasher, quite a rare defect these days.</div><div>ATB,</div><d=
iv>P.</div><div><br></div><div><br><blockquote type=3D"cite"><div>On Dec 12=
, 2025, at 5:19=E2=80=AFPM, Jorge Gustavo Rocha &lt;<a href=3D"mailto:jgr@d=
i.uminho.pt" target=3D"_blank">[email protected]</a>&gt; wrote:</div><br><di=
v><span style=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal=
;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:=
start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0=
px;text-decoration:none;float:none;display:inline">TL;DR</span><br style=3D=
"font-family:HelveticaNeue;font-size:13px;font-style:normal;font-variant-ca=
ps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-inden=
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decorati=
on:none"><br style=3D"font-family:HelveticaNeue;font-size:13px;font-style:n=
ormal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-a=
lign:start;text-indent:0px;text-transform:none;white-space:normal;word-spac=
ing:0px;text-decoration:none"><span style=3D"font-family:HelveticaNeue;font=
-size:13px;font-style:normal;font-variant-caps:normal;font-weight:400;lette=
r-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white=
-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inli=
ne">A GIST index on a EMPTY POLYGON (encoded by GDAL) crashes postgresql wi=
th segmentation fault.</span><br style=3D"font-family:HelveticaNeue;font-si=
ze:13px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-s=
pacing:normal;text-align:start;text-indent:0px;text-transform:none;white-sp=
ace:normal;word-spacing:0px;text-decoration:none"><br style=3D"font-family:=
HelveticaNeue;font-size:13px;font-style:normal;font-variant-caps:normal;fon=
t-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tr=
ansform:none;white-space:normal;word-spacing:0px;text-decoration:none"><spa=
n style=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal;font-=
variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;=
text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;tex=
t-decoration:none;float:none;display:inline">drop table if exists fault;</s=
pan><br style=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal=
;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:=
start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0=
px;text-decoration:none"><span style=3D"font-family:HelveticaNeue;font-size=
:13px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spa=
cing:normal;text-align:start;text-indent:0px;text-transform:none;white-spac=
e:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">c=
reate table fault (fid integer, geom geometry(Polygon,5015));</span><br sty=
le=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal;font-varia=
nt-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-=
indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-dec=
oration:none"><span style=3D"font-family:HelveticaNeue;font-size:13px;font-=
style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal=
;text-align:start;text-indent:0px;text-transform:none;white-space:normal;wo=
rd-spacing:0px;text-decoration:none;float:none;display:inline">INSERT INTO =
fault (fid, geom) VALUES (1, &#39;0103000020971300000100000000000000&#39;::=
GEOMETRY);</span><br 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"><span style=3D"font-family:HelveticaN=
eue;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:4=
00;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:no=
ne;white-space:normal;word-spacing:0px;text-decoration:none;float:none;disp=
lay:inline">CREATE INDEX fault_geom_index ON fault USING GIST (geom);</span=
><br style=3D"font-family:HelveticaNeue;font-size:13px;font-style:normal;fo=
nt-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:sta=
rt;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;=
text-decoration:none"></div></blockquote></div><br></div></div></blockquote=
></div>
</blockquote></div></div>

--0000000000007635c3064606e872--