Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#6408 closed defect (fixed)

ogr2ogr segfauls after SetAttributeFilter() fails

Reported by: Bas Couwenberg Owned by: warmerdam
Priority: high Milestone: 2.0.3
Component: OGR_SF Version: 2.0.2
Severity: major Keywords: vrt
Cc:

Description

As reported by Andy Wood in Debian Bug #817146, after the upgrade to GDAL 2.0.2 ogr2ogr segfaults with the following command:

ogr2ogr -a_srs WGS84 -f GeoJSON -where "ID=098530" -nln "098530" p098530.json argos.xml
ERROR 1: Type mismatch or improper type of arguments to = operator.
FAILURE: SetAttributeFilter(ID=098530) on layer 'argos_trip' failed.
Segmentation fault

gdb backtrace:

(gdb) run
Starting program: /usr/bin/ogr2ogr -a_srs WGS84 -f GeoJSON -where ID=098530 -nln 098530 p098530.json argos.xml
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
ERROR 1: Type mismatch or improper type of arguments to = operator.
FAILURE: SetAttributeFilter(ID=098530) on layer 'argos_trip' failed.

Program received signal SIGSEGV, Segmentation fault.
0x00000000006de240 in ?? ()
(gdb) bt
#0  0x00000000006de240 in ?? ()
#1  0x00007ffff74085cd in GDALDriverManager::~GDALDriverManager() () from /usr/lib/libgdal.so.20
#2  0x00007ffff7408769 in GDALDriverManager::~GDALDriverManager() () from /usr/lib/libgdal.so.20
#3  0x00007ffff7404ca2 in GDALDestroy () from /usr/lib/libgdal.so.20
#4  0x00007ffff7dea857 in _dl_fini () at dl-fini.c:252
#5  0x00007ffff609be02 in __run_exit_handlers (status=status@entry=1, listp=0x7ffff6404698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#6  0x00007ffff609be55 in __GI_exit (status=status@entry=1) at exit.c:104
#7  0x0000000000406c73 in main (nArgc=<optimized out>, papszArgv=0x698240) at ogr2ogr.cpp:1013

Dropping the -where "ID=098530" option allows the command to succeed and exit normally.

Please advise how to best help resolve this issue.

Attachments (2)

argos.xml (410 bytes) - added by Bas Couwenberg 4 years ago.
argos_trip.csv (532 bytes) - added by Bas Couwenberg 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by Bas Couwenberg

Attachment: argos.xml added

Changed 4 years ago by Bas Couwenberg

Attachment: argos_trip.csv added

comment:1 Changed 4 years ago by Even Rouault

Component: UtilitiesOGR_SF
Keywords: vrt added
Resolution: fixed
Status: newclosed

The correct where expression should be -where "ID='098530'" (SQL string literal quoting). But the reason for the crash was due to the VRT driver

Issue was already fixed in trunk per r31484. Just backported in branches/2.0 r33684 "OGR_VRT: implement CloseDependantDataset?() so that exiting with proper closing of datasource doesn't crash (#6408)"

comment:2 Changed 4 years ago by Bas Couwenberg

Awesome, thanks for the quick fix!

In the Debian bugreport I suggested the quoting of the ID value too, to not trigger the type mismatch and subsequent segfault.

I'll include the changes from r33684 as a patch in the Debian package to resolve the issue in the mean time.

Note: See TracTickets for help on using tickets.