Opened 6 years ago

Closed 6 years ago

#4058 closed defect (fixed)

st_curvetoline hangs forever

Reported by: mjurce Owned by: strk
Priority: medium Milestone: PostGIS 2.4.5
Component: postgis Version: 2.4.x
Keywords: Cc:

Description

Trying to convert the geom in attachment out.txt to linear with precision 0.001 it works very fast, but the same geom with precision 0.0001 it hangs forever attached file out2.txt.

Postgis version:

OSTGIS="2.4.3 r16312" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d6" PROJ="Rel. 4.9.2, 08 September 2015" GDAL=" GDAL 1.11.0, released 2014/04/16" LIBXML="2.9.3" RASTER

Attachments (2)

out.txt (27.4 KB ) - added by mjurce 6 years ago.
out2.txt (27.4 KB ) - added by mjurce 6 years ago.

Download all attachments as: .zip

Change History (15)

by mjurce, 6 years ago

Attachment: out.txt added

by mjurce, 6 years ago

Attachment: out2.txt added

comment:1 by mjurce, 6 years ago

Summary: st_curvetoline hangs forveverst_curvetoline hangs forever

comment:2 by robe, 6 years ago

Milestone: PostGIS 2.4.4PostGIS 2.5.0

comment:3 by strk, 6 years ago

Owner: changed from pramsey to strk
Status: newassigned

comment:4 by strk, 6 years ago

Confirmed with r16553 - culprit is an arc with a very large radius, resulting in a computed arc angle=0. I guess we'll want these arcs to be rendered with a single segment:

DEBUG:  [lwstroke.c:lwarc_linearize:156] lwarc_linearize called.
DEBUG:  [lwstroke.c:lwarc_linearize:173]  center is POINT(-11241632062030.3 -11241633632176.3) - radius:1.58981e+13
DEBUG:  [lwstroke.c:lwarc_linearize:250] lwarc_linearize: maxDiff:0.0001, radius:1.58981e+13, halfAngle:0, increment:0 (0 degrees)

comment:5 by strk, 6 years ago

Reduced testcase:

select st_npoints(ST_CurveToLine(
'CIRCULARSTRING(2696000.55.831999999936670, 2695950.552000000141561 1125749.833000000100583, 2695865.195999999996275  1125835.189000)'
::geometry, 0.0001, 1, 0))

comment:6 by robe, 6 years ago

strk which version of geos/postgis are you using?

Your reduced test case does not hang for me:

POSTGIS="2.5.0alpha r16593" [EXTENSION] PGSQL="110" GEOS="3.7.0dev-CAPI-1.11.0 3fe3c03" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.4, released 2018/03/19" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER
select st_npoints(ST_CurveToLine(
'CIRCULARSTRING(2696000.55.831999999936670, 2695950.552000000141561 1125749.833000000100583, 2695865.195999999996275  1125835.189000)'
::geometry, 0.0001, 1, 0))

returns - 49551

comment:7 by robe, 6 years ago

With the attached output2.txt (output.txt is fine) it does hang indefinitely, so I don't think your reduced test case is sufficient to replicate the issue.

comment:8 by robe, 6 years ago

Milestone: PostGIS 2.5.0PostGIS 2.4.5

comment:9 by strk, 6 years ago

It is sufficient here, so it must be related to compiler (how much optimization is done)

What happens is that increment is 0 OR angle+increment results in the same angle over and over again

comment:10 by strk, 6 years ago

Ops, sorry I cannot actually reproduce anymore today so I must have pasted the wrong clipboard, will try again later

comment:11 by strk, 6 years ago

Ok my reduced testcase was using a weird syntax (see #4109). This one reproduces the problem for me:

SELECT ST_CurveToLine(
'CIRCULARSTRING(2696000.553 1125699.831999999936670,
2695950.552000000141561 1125749.833000000100583,
2695865.195999999996275  1125835.189000)'
::geometry, 0.0001,1,0);

And note it is NOT interruptible, so only run in a controlled environment

comment:12 by strk, 6 years ago

Pull request with a fix is ready: https://git.osgeo.org/gitea/postgis/postgis/pulls/25 (only fixes infinite loop, not interruptability)

comment:13 by strk, 6 years ago

Resolution: fixed
Status: assignedclosed

In 16619:

Fix infinite loop in linearization of a big radius small arc

Closes #4058 in 2.4 branch (2.4.5dev)
Includes unit test

Note: See TracTickets for help on using tickets.