<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">One thing we can do is find a reasonable place in the loop to put an interrupt check. Where does it spend its time when it’s in this state?<br><div><br><blockquote type="cite"><div>On Apr 20, 2023, at 5:31 PM, Martin Davis <mtnclimb@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">That geometry is indeed a simple rectangle, but it's very, very, very narrow. This is causing the interative algorithm used in MaximmumInscribedCircle to essentially hunt forever trying to find a point which lies inside the polygon.<div><br></div><div>Of course it would be nice to detect this situation and terminate faster, either with a point which lies actually lies outside the rectangle, or some other return value. This will require some thought.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 20, 2023 at 2:38 PM Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Hello dear Postgis devs!<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">I have a strange case to submit to you.<br></div><div class="gmail_default" style="font-family:monospace,monospace">In a nutshell, trying to compute <br></div><div class="gmail_default" style="font-family:monospace,monospace">```SQL<br>SELECT ST_MaximumInscribedCircle( 'POLYGON ((59.3 100.00000000000001, 99.7 100.00000000000001, 99.7 100, 59.3 100, 59.3 100.00000000000001))') ;<br>```</div><div class="gmail_default" style="font-family:monospace,monospace">causes it to run for many minutes until it eventually errors.</div><div class="gmail_default" style="font-family:monospace,monospace">Worst, running this kind of computing on 12M geoms in parallel x6 created a postgres **segfault** and crashed my server (16 cores, 64GB).</div><div class="gmail_default" style="font-family:monospace,monospace">(many more geoms are making this function unhappy).</div><div class="gmail_default" style="font-family:monospace,monospace"><br>/!\ Once this query starts, it can't be stopped by `pg_cancel_backend(pid)` or even `pg_terminate_backend(pid)`</div><div class="gmail_default" style="font-family:monospace,monospace">--> This is pretty dangerous in my opinion.<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">The geometry is simple, it is a rectangle.<br></div><div class="gmail_default" style="font-family:monospace,monospace">I obtained it through other geometry operations</div><div class="gmail_default" style="font-family:monospace,monospace">It must be some kind of precision issue, I'm wondering if there is some kind of infinite loop going on or something.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">My full code is something like that:<br></div><div class="gmail_default" style="font-family:monospace,monospace">```SQL<br>SELECT env, diff, ST_MaximumInscribedCircle(diff)<br>FROM CAST ('some_polygon'as text ) as g<br> , ST_Envelope(g) as env<br> , ST_MakeEnvelope(0,0,100,100) as bound<br> , ST_Difference(env, bound) as diff;<br>```</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Not creating a bug ticket as I don't know if I'm simply abusing the function / using it in a way it should not.<br></div> <div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">POSTGIS="3.1.7 aafe1ff" [EXTENSION] PGSQL="140" GEOS="3.9.1-CAPI-1.14.2" PROJ="8.0.1" GDAL="GDAL 3.4.3, released 2022/04/22" LIBXML="2.9.1" LIBJSON="0.15" LIBPROTOBUF="1.3.2" WAGYU="0.5.0 (Internal)" RASTER</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">PostgreSQL 14.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit</div></div>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
</blockquote></div>
_______________________________________________<br>postgis-devel mailing list<br>postgis-devel@lists.osgeo.org<br>https://lists.osgeo.org/mailman/listinfo/postgis-devel<br></div></blockquote></div><br></body></html>