Opened 2 years ago
Last modified 2 years ago
#5320 closed defect
ST_SimplifyPreserveTopology crashes with infinity coordinates — at Version 9
Reported by: | robe | Owned by: | robe |
---|---|---|---|
Priority: | blocker | Milestone: | PostGIS 3.0.9 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description (last modified by )
Change History (9)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
comment:3 by , 2 years ago
The question, as always for these kinds of things, is where to put the fix. We could put a big "no infinites" test at the PostGIS level, before calling into GEOS. Or we could put a test in Quadtree::Root to throw an exception in the case of infinite envelopes, since the Quadtree code is definitely not infinite-safe. I lean towards the latter as the "correct" fix, but it means this won't be fixed "in postgis", but in a patch release of GEOS.
follow-up: 7 comment:4 by , 2 years ago
GEOS is generally not infinite-ordinate-safe. Is it going to be a whack-a-mole exercise to find all of them and add checks? If so, maybe it is best to check for Inf on the PG side, when creating GEOS geometries for passing to GEOS functions?
comment:5 by , 2 years ago
I think the fix should eventually go into GEOS, but given it seems at moment we have only 3 functions in PostGIS impacted, seemed harmless enough to fix at the postgis level.
We do have ST_SetPoint #5319 impacted as well, which is not a GEOS function as I recall, so we still need an easy way to trap infinites on the postgis side.
comment:6 by , 2 years ago
P.S. I didn't test SFCGAL, but I suspect we might have similar issues there too.
follow-up: 8 comment:7 by , 2 years ago
Replying to mdavis:
GEOS is generally not infinite-ordinate-safe.
And yet Envelope says that it can sometimes hold infinite sided bounds! Gah!
I think in general having known infinite loops in GEOS is bad? Like, "feed this function an Inf and it'll lock up on you". So a GEOS patch is not a bad idea?
comment:8 by , 2 years ago
Replying to pramsey:
I think in general having known infinite loops in GEOS is bad? Like, "feed this function an Inf and it'll lock up on you". So a GEOS patch is not a bad idea?
The bright light of a new day has clarified my thinking. Yes, I agree that GEOS should be fixed so that it does not crash for any inputs.
A fix in Quadtree
is probably the minimum required, for this case. I wonder how to fix all the other potential cases of Inf causing crashes? It's tempting to put a check in Envelope creation... but maybe that's too pervasive.
For sure validity checking should be tightened up to report Inf ordinates as invalid.
comment:9 by , 2 years ago
Description: | modified (diff) |
---|
backtrace for this