-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new segfault with GEOS 3.10.0beta2, OK in 3.9.1 #1809
Comments
|
|
|
|
GDB: |
|
In base sf, you need an extra non-default argument to create a non-closed polygon ( but in the WKT case, unlike I don't think GEOS 3.10.0 should cause a segfault when 3.9.1 didn't, but something has changed in trapping the exception, and arguably |
|
Interestingly: so is the error handler not working and the error not being trapped? Is HAVE350 being detected? Adding an so yes, detected. |
|
Commenting out the but also no |
|
I wonder if the error handler is doing a https://github.com/paleolimbot/geos/blob/master/src/geos-common.c#L5-L18 https://github.com/paleolimbot/geos/blob/master/src/geos-io.c#L25 |
|
@paleolimbot thanks for joining in. I cannot see where else to try things here, |
|
Thanks; building a docker image now, not sure if I get to this before tomorrow evening. |
|
It looks like the message handler gets called in isValid on exception: https://github.com/libgeos/geos/blob/main/capi/geos_ts_c.cpp#L707 ...and that the https://github.com/r-spatial/sf/blob/master/src/geos.cpp#L1142-L1144 Could you pass |
|
Right, but Lines 546 to 576 in 30cccf5
from https://trac.osgeo.org/geos/wiki/TopologyExceptions, but checking validity is not the same as a predicate or operation. |
|
I'm finding it hard to understand how you are calling things. Is it possible to make a standalone that dies? The was a big re-write in IsValidOp, so that's where things changed most likely. |
|
We see that where before an unclosed polygon threw an exception (correctly) which we could trap, now the same code segfaults with memory not mapped. We'll try to create a standalone, but two of us are CEST, so it will take time. Might the code fail even before getting to validity checking, has the polygon creation code also changed? @edzer the same difference is found with released sf as with master latest, which was what I started by testing. |
|
So, I made up a little unit test GEOSCoordSequence* shell_seq = GEOSCoordSeq_create(4, 2);
double shell_coords[] = {0,0, 0,10, 10,10, 10,0};
for (unsigned int i = 0; i < 4; i++) {
GEOSCoordSeq_setXY(shell_seq, i, shell_coords[2*i], shell_coords[2*i+1]);
}
GEOSGeometry* shell = GEOSGeom_createLinearRing(shell_seq);
ensure(shell != nullptr);
GEOSGeometry* polygon = GEOSGeom_createPolygon(shell, nullptr, 0);
ensure(polygon != nullptr);
char isvalid = GEOSisValid(polygon);
ensure_equals(0, isvalid);
GEOSGeom_destroy(polygon);I get |
|
Yeah, seems odd, you should be getting a notice and a null return when you attempt to create an unclosed LinearRing. |
|
It looks like there's no https://github.com/r-spatial/sf/blob/master/src/geos.cpp#L168 There are a lot of other places in geos.cpp without NULL checks, too, although there is a function to check for a null geometry: https://github.com/r-spatial/sf/blob/master/src/geos.cpp#L701-L706 I haven't tested this for memory leaks, but I think that sf is leaking the context object whenever this throws! My strategy in the 'geos' package is a global context object so that I don't have to worry about leaking that particular object. |
|
It looks like @paleolimbot found the right spot; checking here for a It seems that this is new behavior of GEOS, but makes complete sense IMO. |
|
I have in the where both |
|
I also see that |
|
Thanks everyone, very helpful - should work now! |
|
Looks good here too, no segfault with GEOS 3.10.0beta2. |
|
So, an FYI. The fact that you could pass nullptr into |
and
Simplified:
The text was updated successfully, but these errors were encountered: