Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
GEOS aborting with "Assertion failed" on OS X, discussion and work around #553
I've spent a bit of free time looking more deeply into the reports of GEOS aborting in the AbstractSTRtree.cpp module (either in
Here are the conditions for a program that will unexpectedly abort:
Here's an example program:
import fiona from shapely.geometry import Point from shapely.geos import geos_version from shapely.ops import unary_union print(geos_version) SHAPES = [Point(i, i).buffer(1.5) for i in range(20)] for i, s in enumerate(SHAPES): print(i, s.is_valid) print(i, s.wkt) print(i, s.area, s.length) print(i, s.intersects(Point(10, 10).buffer(8.0))) union = unary_union(SHAPES) print(union)
I've run the script under lldb with a modified version of GEOS 3.6.2 that prints some debugging output before calling
I've failed to get access to variables in the frame where
The problem in
If fiona is imported after shapely, the programs (either with
My hypothesis is that there is a race condition in initialization of the libgeos-3.6.2 library that leaves some objects in the AbstractSTRtree.cpp module in a partly or improperly initialized state when we dlopen the GEOS lib after it has already been loaded in the process via import of fiona. Use of GEOS as both a dependent library of fiona modules and as a library we dynamically load during import of shapely is a little weird, I grant, but doesn't necessarily have to trigger crashing bugs. There's no problem on Linux. I see some hints that the difference between ELF and Mach-O might be important.
Install the GEOS library to one standard location on your macosx system using homebrew, fink, macports, or from source, do the same for GDAL, and then install fiona and shapely like so:
You can import fiona and shapely in any order if you do this.
On OS X, if you're using fiona and shapely wheels together, import shapely first. It's annoying to have to do this, I know. Abstracting away the C/C++ details of GEOS and GDAL has been one of my main design principles for fiona and shapely, and I'm falling short.
I think there's a race condition bug to be fixed in the GEOS library. You can see some indication of that at https://lists.osgeo.org/pipermail/geos-devel/2017-November/008157.html. Because this doesn't affect Linux and PostGIS, it's a very low-flying bug.
Fixing it will require more knowledge and experience with C++ and dynamic library building and loading on Mac OS X than I currently have, and so the fix isn't going to be coming soon unless we can get some help.
I'm somewhat content to at least have a master ticket that I can point users at. It's a start.
This was referenced
Jan 1, 2018
Hi, I am not using Fiona, only shapely. I was trying to use Shapely's parallel_offset(). Building the program in the terminal is fine but when I tend to check my browser, it crashes with the alert that "Python quit unexpectedly." In my python console, the error says
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
I'm getting the same error (
referenced this issue
Jul 9, 2018
I do not use fiona, but was still experiencing this issue. I first attributed it to spatialite, since I am attempting to get Python 2.7.15 running on OS X and rebuilding libspatialite. Using the --no-binary flag in pip solved my issue it appears.
Using the geometry.split method I am getting the same error. I tried installing shapely with the following and still getting the error. Can I not specify a version in this no-binary approach? the reason i have to use --ignore-installed is because I already have a version of Shapely installed that i cannot remove because it's a 'distutils installed project' which I don't quite grok yet.
pip install --ignore-installed --trusted-host pypi.org --trusted-host files.pythonhosted.org --no-binary shapely==1.6.4.post2,fiona shapely==1.6.4.post2 fiona
Just to add to this thread, I'm seeing the same behavior in a virtualenv that meets the above descriptions.
Re-installing from source for Fiona and Shapely did not fix the problem.
I did some digging in my virtualenv and found the geos binary installed by rasterio:
This appears to have fixed it: