Fiona: Segmentation fault when reading from a closed Fiona handler

Created on 19 Nov 2018  路  4Comments  路  Source: Toblerity/Fiona

I use Fiona 1.8.0, and got this error. (I've checked, this exact problem has't been written here in the issues) Here's a test file and a code that crashes with it:

crash-test.geojson:

{
"type": "FeatureCollection",
"name": "crash-test",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "fid": 1 }, "geometry": { "type": "Point", "coordinates": [ 82.962057955238649, 55.020673993066666 ] } },
{ "type": "Feature", "properties": { "fid": 2 }, "geometry": { "type": "Point", "coordinates": [ 82.947699391022894, 55.018927881501845 ] } },
{ "type": "Feature", "properties": { "fid": 3 }, "geometry": { "type": "Point", "coordinates": [ 82.934646150826737, 55.017306424092794 ] } }
]
}

And the code that crashes:

import fiona
f = fiona.open('crash-test.geojson', driver='GeoJSON')
i = iter(f)

while True:
    try:
        next(i)
    except StopIteration:
        f.close()
        break

try:
    next(i)
    print('we shouldn\'t arrive here')
except Exception as e:
    print('we should arrive here')
    print(e)

print('end')

Expected result: exit and print exception information.
Actual result:

$ python3 test.py 
Segmentation fault (core dumped)
bug

All 4 comments

With fiona 1.8.1 on linux with gdal 2.3.2 I get:

python3 crash.py 
ERROR 10: Pointer 'hLayer' is NULL in 'OGR_L_GetNextFeature'.

we should arrive here

end

What OS and gdal version are you using?
You can use fiona.get_gdal_release_name() to find out your gdal version.

I can reproduce the crash with Fiona 1.8.1 and GDAL master on Ubuntu 18.04.

(gdb) run tester.py
Starting program: /home/sean/.local/share/virtualenvs/Fiona-BSAmxRUl/bin/python tester.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
OGR_L_GetNextFeature (hLayer=0xb3) at ogrlayer.cpp:552
552                 OGRLayer::FromHandle(hLayer)->GetNextFeature());

I have Ubuntu 18.04 too, GDAL release name '2.3.2'

Upgraded Fiona to 1.8.2, and it's fixed, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klonuo picture klonuo  路  3Comments

sgillies picture sgillies  路  3Comments

jamesmyatt picture jamesmyatt  路  4Comments

kylebarron picture kylebarron  路  5Comments

keithamoss picture keithamoss  路  3Comments