Opened 19 months ago

Last modified 4 months ago

#27399 new Bug

Segfault when running GDALBandTests on OSX 10.11.6

Reported by: Tatiana Vasilevskaya Owned by: nobody
Component: GIS Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When running gis_tests.gdal_tests.test_raster.GDALBandTests tests on OSX 10.11.6 django calls capi.open_ds inside GDALRaster. This results in a Segmentation fault. Occurs on the master branch (80e742d991b276023a3aa51a29ed757879051282).

-> options.exclude_tags,
-> extra_tests=extra_tests,
-> result = self.run_suite(suite)
-> return
-> test(result)
-> return*args, **kwds)
-> test(result)
-> super(SimpleTestCase, self).__call__(result)
-> return*args, **kwds)
-> self.setUp()
> /Users/vasilty/Documents/Projects/django/tests/gis_tests/gdal_tests/
-> self.rs_path = os.path.join(os.path.dirname(upath(__file__)), '../data/rasters/raster.tif')

TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
Segmentation fault: 11

Change History (7)

comment:1 Changed 19 months ago by Markus Holtermann

Triage Stage: UnreviewedAccepted

comment:2 Changed 19 months ago by Tim Graham

Do you have any details about why Django might be at fault? We don't ship any C code, so segfaults are generally not caused by Django.

comment:3 Changed 19 months ago by Markus Holtermann

Even if we don't ship C code, either our documentation lacks some details on supported GDAL / GIS versions (that's beyond my knowledge) or we should check for that. Either way, I don't think Django's test should segfault regardless.

comment:4 Changed 19 months ago by Tim Graham

What are the installed GIS library versions? Did you reproduce the issue, Markus?

Last edited 19 months ago by Tim Graham (previous) (diff)

comment:5 Changed 19 months ago by Saulius Žemaitaitis

I can still reproduce it on master (24c9cce1c9fb0dfe14e42de1ec2a2a209a64dd80).

OSX 10.11.6

Library versions (installed from Homebrew):

gdal 1.11.5_1
geos 3.5.0
libgeotiff 1.4.1_2
liblwgeom 2.1.5_3
libtiff 4.0.6_2

GDB backtrace:

#0  0x000000010308f0b6 in _TIFFVGetField () from /Users/saulius/sandbox/duth2016/django/env/lib/python3.5/site-packages/PIL/.dylibs/libtiff.5.dylib
#1  0x0000000105332010 in TIFFGetField () from /usr/local/opt/libtiff/lib/libtiff.5.dylib
#2  0x0000000104a21b61 in GTiffDataset::OpenOffset(tiff*, GTiffDataset**, unsigned long, int, GDALAccess, int, int, char**) () from /usr/local/lib/libgdal.dylib
#3  0x0000000104a24a64 in GTiffDataset::Open(GDALOpenInfo*) () from /usr/local/lib/libgdal.dylib
#4  0x0000000104b956d9 in GDALOpenInternal(GDALOpenInfo&, char const* const*) () from /usr/local/lib/libgdal.dylib
#5  0x0000000104b95580 in GDALOpenInternal(char const*, GDALAccess, char const* const*) () from /usr/local/lib/libgdal.dylib
#6  0x0000000102e3f79f in ffi_call_unix64 () from /Users/saulius/sandbox/duth2016/django/env/lib/python3.5/lib-dynload/
#7  0x0000000102e3ffd8 in ffi_call () from /Users/saulius/sandbox/duth2016/django/env/lib/python3.5/lib-dynload/
#8  0x0000000102e3b89a in _ctypes_callproc () from /Users/saulius/sandbox/duth2016/django/env/lib/python3.5/lib-dynload/
#9  0x0000000102e36473 in PyCFuncPtr_call () from /Users/saulius/sandbox/duth2016/django/env/lib/python3.5/lib-dynload/
#10 0x000000010000ecb5 in PyObject_Call () from /usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/Python
Last edited 19 months ago by Saulius Žemaitaitis (previous) (diff)

comment:6 Changed 19 months ago by Saulius Žemaitaitis

The problem seems to be due to the way Pillow and GDAL interact. Pillow wheel ships its own version of libtiff while GDAL library uses the system one. This apparently causes the segfault. I don't have the skills to narrow it down further.

Workaround is to install Pillow from source on OSX:

pip install --no-binary Pillow -r tests/requirements/py3.txt

comment:7 Changed 4 months ago by winsent

Look at this example. Install only pillow and Django without GDAL python binding. This code raise exeption after pillow installed.


virtualenv --python=python3 test
cd test
source bin/activate
pip install django==1.11.9 pillow
python -c "from django.contrib.gis.gdal import GDALRaster; print(GDALRaster('$GEOTIF_PATH'))"
django-admin startproject testtest
cd testtest
django-admin startapp testtesttest
echo "\n\nINSTALLED_APPS += ['testtesttest']" >> testtest/
mkdir -p testtesttest/management/commands
touch testtesttest/management/ testtesttest/management/commands/
echo "from import BaseCommand
class Command(BaseCommand):
    def handle(self, *args, **options):
        from django.contrib.gis.gdal import GDALRaster
" > testtesttest/management/commands/
python gdal_test
pip uninstall -y pillow
python gdal_test


TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
[1]    53998 bus error  python gdal_test
Note: See TracTickets for help on using tickets.
Back to Top