Skip to content
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

ogr.ForceTo SegFault for specific permutations #2120

Closed
davethejoy opened this issue Dec 18, 2019 · 2 comments
Closed

ogr.ForceTo SegFault for specific permutations #2120

davethejoy opened this issue Dec 18, 2019 · 2 comments

Comments

@davethejoy
Copy link

I am writing conversion code to cast any geometry type to any geometry type. As part of my test suite, I have library of WKTs ( which are all valid: geom.IsValid() == True ) however some of the conversion permutations causes a segfault

MacOSX 10.14.5 (mojave)
Anaconda Python 3.7.4 64 bits
GDAL version 3.0.2

pip freeze
affine==2.3.0
alabaster==0.7.12
anaconda-client==1.7.2
anaconda-navigator==1.9.7
anaconda-project==0.8.3
appnope==0.1.0
appscript==1.0.1
asn1crypto==1.2.0
astroid==2.3.2
astropy==3.2.2
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.4.4
Babel==2.7.0
backcall==0.1.0
backports.functools-lru-cache==1.5
backports.os==0.1.1
backports.shutil-get-terminal-size==1.0.0
backports.tempfile==1.0
backports.weakref==1.0.post1
beautifulsoup4==4.8.1
bitarray==1.0.1
bkcharts==0.2
bleach==3.1.0
bokeh==1.3.4
boto==2.49.0
Bottleneck==1.2.1
certifi==2019.9.11
cffi==1.13.1
chardet==3.0.4
Click==7.0
click-plugins==1.1.1
cligj==0.5.0
cloudpickle==1.2.2
clyent==1.2.2
colorama==0.4.1
conda==4.7.12
conda-package-handling==1.6.0
conda-tree==0.0.5
conda-verify==3.4.2
contextlib2==0.6.0
cryptography==2.8
cycler==0.10.0
Cython==0.29.13
cytoolz==0.10.0
dask==2.6.0
dateparser==0.7.2
decorator==4.4.1
defusedxml==0.6.0
distributed==2.6.0
docutils==0.15.2
entrypoints==0.3
et-xmlfile==1.0.1
fastcache==1.1.0
filelock==3.0.12
Fiona==1.8.11
Flask==1.1.1
fsspec==0.5.2
future==0.17.1
GDAL==3.0.2
geopandas==0.6.1
gevent==1.4.0
glob2==0.7
gmpy2==2.0.8
graphviz==0.13.2
greenlet==0.4.15
grpcio==1.25.0
grpcio-tools==1.25.0
h5py==2.9.0
HeapDict==1.0.1
html5lib==1.0.1
idna==2.8
imageio==2.6.1
imagesize==1.1.0
importlib-metadata==0.23
ipykernel==5.1.3
ipython==7.9.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
isort==4.3.21
itsdangerous==1.1.0
jdcal==1.4.1
jedi==0.15.1
Jinja2==2.10.3
joblib==0.13.2
json5==0.8.5
jsonschema==3.1.1
jupyter==1.0.0
jupyter-client==5.3.4
jupyter-console==6.0.0
jupyter-core==4.6.0
jupyterlab==1.1.4
jupyterlab-server==1.0.6
keyring==18.0.0
kiwisolver==1.1.0
lazy-object-proxy==1.4.2
libarchive-c==2.8
lief==0.9.0
llvmlite==0.30.0
locket==0.2.0
lxml==4.4.1
MarkupSafe==1.1.1
matplotlib==3.1.1
mccabe==0.6.1
mistune==0.8.4
mkl-fft==1.0.14
mkl-random==1.1.0
mkl-service==2.3.0
mock==3.0.5
more-itertools==7.2.0
mpmath==1.1.0
msgpack==0.6.1
multipledispatch==0.6.0
munch==2.5.0
navigator-updater==0.2.1
nbconvert==5.6.0
nbformat==4.4.0
networkx==2.4
nltk==3.4.5
nose==1.3.7
notebook==6.0.1
numba==0.46.0
numexpr==2.7.0
numpy==1.17.2
numpydoc==0.9.1
olefile==0.46
openpyxl==3.0.0
packaging==19.2
pandas==0.25.2
pandocfilters==1.4.2
parso==0.5.1
partd==1.0.0
path.py==12.0.1
pathlib2==2.3.5
patsy==0.5.1
pep8==1.7.1
pexpect==4.7.0
pickleshare==0.7.5
Pillow==6.2.0
pkginfo==1.5.0.1
pluggy==0.13.0
ply==3.11
prometheus-client==0.7.1
prompt-toolkit==2.0.10
protobuf==3.9.2
psutil==5.6.3
ptyprocess==0.6.0
py==1.8.0
pycodestyle==2.5.0
pycosat==0.6.3
pycparser==2.19
pycrypto==2.6.1
pycurl==7.43.0.3
pyflakes==2.1.1
Pygments==2.4.2
pylint==2.4.3
pyodbc==4.0.27
pyOpenSSL==19.0.0
pyparsing==2.4.2
pyproj==2.4.1
pyrsistent==0.15.4
PySocks==1.7.1
pytest==5.2.2
pytest-arraydiff==0.3
pytest-astropy==0.5.0
pytest-doctestplus==0.4.0
pytest-openfiles==0.4.0
pytest-remotedata==0.3.2
python-dateutil==2.8.0
pytz==2019.3
PyWavelets==1.0.3
PyYAML==5.1.2
pyzmq==18.1.0
QtAwesome==0.6.0
qtconsole==4.5.5
QtPy==1.9.0
rasterio==1.1.0
regex==2019.12.9
requests==2.22.0
rope==0.14.0
Rtree==0.8.3
ruamel-yaml==0.15.46
scikit-image==0.15.0
scikit-learn==0.21.3
scipy==1.3.1
seaborn==0.9.0
Send2Trash==1.5.0
Shapely==1.6.4.post2
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.12.0
snowballstemmer==2.0.0
snuggs==1.4.7
sortedcollections==1.1.2
sortedcontainers==2.1.0
soupsieve==1.9.3
Sphinx==2.2.1
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
sphinxcontrib-websupport==1.1.2
spyder==3.3.6
spyder-kernels==0.5.2
SQLAlchemy==1.3.10
statsmodels==0.10.1
sympy==1.4
tables==3.5.2
tblib==1.4.0
terminado==0.8.2
testpath==0.4.2
toolz==0.10.0
tornado==6.0.3
tqdm==4.36.1
traitlets==4.3.3
triangle==20190115.3
tzlocal==2.0.0
unicodecsv==0.14.1
urllib3==1.24.2
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.16.0
widgetsnbextension==3.5.1
wrapt==1.11.2
wurlitzer==1.0.3
xlrd==1.2.0
XlsxWriter==1.2.2
xlwings==0.16.0
xlwt==1.3.0
zict==1.0.0
zipp==0.6.0

import ogr
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON Z (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON Z (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON Z (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON Z (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveZM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON M (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON M (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON M (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON M (((-122.3361708 47.6036156 0,-122.3365181 47.6034677 0,-122.3364587 47.6034043 0,-122.3363155 47.6032514 0,-122.3360143 47.6029298 0,-122.3356669 47.6030777 0,-122.3361708 47.6036156 0)))' ), ogr.wkbCompoundCurveZM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON ZM (((-122.3361708 47.6036156 0 0,-122.3365181 47.6034677 0 0,-122.3364587 47.6034043 0 0,-122.3363155 47.6032514 0 0,-122.3360143 47.6029298 0 0,-122.3356669 47.6030777 0 0,-122.3361708 47.6036156 0 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON ZM (((-122.3361708 47.6036156 0 0,-122.3365181 47.6034677 0 0,-122.3364587 47.6034043 0 0,-122.3363155 47.6032514 0 0,-122.3360143 47.6029298 0 0,-122.3356669 47.6030777 0 0,-122.3361708 47.6036156 0 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON ZM (((-122.3361708 47.6036156 0 0,-122.3365181 47.6034677 0 0,-122.3364587 47.6034043 0 0,-122.3363155 47.6032514 0 0,-122.3360143 47.6029298 0 0,-122.3356669 47.6030777 0 0,-122.3361708 47.6036156 0 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON ZM (((-122.3361708 47.6036156 0 0,-122.3365181 47.6034677 0 0,-122.3364587 47.6034043 0 0,-122.3363155 47.6032514 0 0,-122.3360143 47.6029298 0 0,-122.3356669 47.6030777 0 0,-122.3361708 47.6036156 0 0)))' ), ogr.wkbCompoundCurveZM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE M (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE M (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE M (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE M (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveZM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE Z (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE Z (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE Z (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE Z (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurveZM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE ZM (((0 0 0 0,0 1 0 0,1 1 0 0,0 0 0 0)))' ), ogr.wkbCompoundCurve )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE ZM (((0 0 0 0,0 1 0 0,1 1 0 0,0 0 0 0)))' ), ogr.wkbCompoundCurveM )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE ZM (((0 0 0 0,0 1 0 0,1 1 0 0,0 0 0 0)))' ), ogr.wkbCompoundCurveZ )
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTISURFACE ZM (((0 0 0 0,0 1 0 0,1 1 0 0,0 0 0 0)))' ), ogr.wkbCompoundCurveZM )
$ python ForceToSegFault.py 
ERROR 1: Linearring not allowed.
Segmentation fault: 11
@rouault
Copy link
Member

rouault commented Dec 18, 2019

Short reproducer

from osgeo import ogr
ogr.ForceTo( ogr.CreateGeometryFromWkt( 'MULTIPOLYGON Z (((0 0 0,0 1 0,1 1 0,0 0 0)))' ), ogr.wkbCompoundCurve )

The fact that it is a MultiPolygon Z and not a MultiPolygon is essential to the reproduction

rouault added a commit that referenced this issue Dec 18, 2019
rouault added a commit that referenced this issue Dec 18, 2019
@davethejoy
Copy link
Author

Awesome! tx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants