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
Seg fault with python 2.7 rasterio 1.1.0 wheel #1805
Comments
@glostis what happens if you import rasterio after pyproj ? |
@vincentsarago What exactly do you mean by importing after? The import pyproj
import rasterio
pyproj.Proj(init="epsg:4326")
print("ok") I have also tried it the other way around: import rasterio
import pyproj
pyproj.Proj(init="epsg:4326")
print("ok") and it produces the same result. |
oh yeah sorry I meant the opposite 🤦♂
just to be sure, when rasterio is imported I guess the problem is that pyproj built from wheel will use GDAL3 while rasterio wheel is shipped with GDAL 2.4 when working with shapely/pyproj/rasterio together I alway try to avoid using wheels to avoid the segfault, I think there is an old issue in rasterio or fiona repo about that |
Yes it produces the same
I see. However the thing that surprises me is that my experiment works with the
Yes I guess installing the |
@vincentsarago yes, I think your diagnosis is right, except that I'm sure that the library causing us trouble is proj, not gdal. The difference between Python 2.7 and 3.6 is curious. In rasterio 1.1b1 we had a dataset reference counting bug that only caused segfaults for Python 2.7. A module compiled with the 3.6 Python SDK is more fault tolerant for reasons I don't understand. |
…n python 2.7 More info: rasterio/rasterio#1805
Thanks for looking into this @sgillies and @vincentsarago! Do you think this issue could be solved by changing something in the lastest How could I go about debugging this issue? |
@glostis the rasterio wheels aren't built any differently for 1.1.0. PROJ and GDAL are built the same way. Rasterio 1.1.0 did add a new _transform module but I don't see anything out of the ordinary there. Did your pyproj version change between your builds? I'm pretty much finished with Python 2.7 and will be ignoring problems that only crop up there starting in 2020. Rasterio is going to stop testing against Python 2.7 soon. That's not to say that I don't want to know why this is happening. |
What versions of pyproj for each scenario? |
Sorry for the late response. As you can see in my Dockerfile, I was testing the bug on 4 different python virtualenvs:
In each virtualenv, I was simply requiring the latest version of I have rerun my Dockerfile by forcing To sum up, this bug occurs on python environments with I hope this clarifies things a little. |
There were some fixes in the latest pyproj and PROJ in the wheels in (2.4.0) that prevents core dumping in specific scenarios. So, I bet it is related. Not sure why importing rasterio would impact it though. Interesting 🤔 |
@snowman2 can you link to the changes? I'd like to take a look. After that, I'm going to close this issue. The solutions are outside the scope of the rasterio project. |
I think this is definitely related to the fix in pyproj/PROJ. Does importing rasterio set the More details in related issue: OSGeo/PROJ#1574 |
@snowman2 yes, when we import rasterio it peeks in the process environment and if PROJ_LIB is not set, and the rasterio package contains PROJ data (from a wheel), it patches the environment https://github.com/mapbox/rasterio/blob/059ad3e01c0da363c99cd1f2ca6c4e3353c1485c/rasterio/env.py#L648-L654. The behavior is the same in 1.0.28 and 1.1.0. |
That throws a wrench in the PROJ only theory. Any difference in the PROJ/GDAL versions in the rasterio wheels? |
No. It's PROJ 4.9.3 and GDAL 2.4.2 in each. |
It is definitely related to this issue OSGeo/PROJ#1574. I created and environment with
I then tested out unsetting >>> import rasterio
>>> import pyproj
>>> import os
>>> proj_lib = os.environ.pop("PROJ_LIB")
>>> pyproj.Proj(init="epsg:4326")
Proj('+proj=longlat +datum=WGS84 +no_defs', preserve_units=True)
>>> os.environ["PROJ_LIB"] = proj_lib
>>> pyproj.Proj(init="epsg:4326")
Segmentation fault (core dumped) |
However, with >>> import rasterio, os
>>> os.environ["PROJ_LIB"]
Traceback (most recent call last):
...
raise KeyError(key) from None
KeyError: 'PROJ_LIB' |
@sgillies if I am not mistaken, the lines you refer to, which set the @snowman2 has shown above that it is the presence of this env var that is clashing with |
@glostis no, 1.0.28 did set PROJ_LIB, but as I look more closely I remember that we removed these two lines in 1.1: https://github.com/mapbox/rasterio/blob/1.0.28/rasterio/env.py#L644-L646. The reason: PROJ data at a system path might be for a different version of PROJ than the one needed by rasterio in a wheel. |
Well, this is a PROJ/pyproj issue that has been resolved in |
Hi,
I have encountered failing Travis builds on one of my projects following the latest
rasterio
release (1.1.0
).My Travis build tests both python 3.7 and 2.7, and only the build on 2.7 started failing.
It was an end-to-end test, but I have managed to narrow it down to a very minimal example, shown below.
TL;DR: importing
rasterio
in a script that executespyproj
crashes with a Segmentation fault with therasterio-1.1.0-cp27-cp27mu-manylinux1_x86_64.whl
wheel.Steps to reproduce the problem.
I have included a
.zip
with theDockerfile
and the two python scripts needed to reproduce the problem.rio_bug.zip
For easier readability, here is the
Dockerfile
and the two python scripts:expand Dockerfile
expand with_rasterio.py
expand without_rasterio.py
The
Dockerfile
basically runs the two python scripts with a matrix of python versions (2
/3
) andrasterio
versions (1.0.28
/1.1.0
).Building and running this
Dockerfile
gives the following output:As you can see, there is one failing case among the 8 configurations:
python2.7
withrasterio 1.1.0
.I didn't see anything obvious in the changelog from
1.0.28
to1.1.0
that could explain this error, especially due to the fact that it only occurs inpython2.7
.The text was updated successfully, but these errors were encountered: