Opened 11 years ago

Closed 11 years ago

#2201 closed defect (fixed)

ogrinfo/ogr2ogr with interlis 1 gives segmentation fault (without ili file!)

Reported by: meierrom Owned by: pka
Priority: normal Milestone: 1.5.1
Component: OGR_SF Version: unspecified
Severity: normal Keywords: interlis 1
Cc: warmerdam

Description

ogrinfo and ogr2ogr throw out a segmentation fault with interlis 1 files without adding an ili file. Processing stops almost immediately after pressing the enter key.

Here some examples: ogrinfo beispiel.itf --> Segmentation fault ogr2ogr -f 'PostgreSQL' PG:'dbname=test user=test' test.shp --> works fine ogr2ogr -f 'PostgreSQL' PG:'dbname=test user=test' beispiel.itf,beispiel.ili --> works fine ogr2ogr -f 'PostgreSQL' PG:'dbname=test user=test' beispiel.itf --> Segmentation fault

I used mainly the two following configure strings: ./configure --with-xerces --without-geos ./configure --with-xerces --without-geos --with-pg=/usr/local/pgsql/bin/pg_config

I tried several gdal/ogr versions, releases and trunks, f.e. 1.4.2, 1.4.3, 1.5.0, etc.

I compiled on opensuse 7.3 and 10.2.

I tried several compilers up to 4.1.2.

I tried two xerces-libs: 2.6.0 and 2.8.0.

All the best!!! Roman

Attachments (1)

beispiel.itf (1.0 KB) - added by meierrom 11 years ago.
file for testing

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by meierrom

Attachment: beispiel.itf added

file for testing

comment:1 Changed 11 years ago by Even Rouault

Component: UtilitiesOGR_SF
Keywords: interlis 1 added

Confirmed :

$ CPL_DEBUG= valgrind apps/ogrinfo -ro -al beispiel.itf
==30842== Memcheck, a memory error detector.
==30842== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==30842== Using LibVEX rev 1732, a library for dynamic binary translation.
==30842== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==30842== Using valgrind-3.2.3-Debian, a dynamic binary instrumentation framework.
==30842== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==30842== For more details, rerun with: -v
==30842==
GPX: XML parsing of file failed : syntax error at line 1, column 0
KML: XML parsing of file failed : syntax error at line 1, column 0
KML: Valid: 0 Version:
OGR_ILI: Reading table 'Bodenbedeckung__BoFlaechen_Form'
OGR_ILI: No model found, using default field names.
OGR_ILI: No field definition found for table: Bodenbedeckung__BoFlaechen_Form
==30842== Invalid read of size 4
==30842==    at 0x4497001: OGRFeature::IsFieldSet(int) const (ogr_feature.h:195)
==30842==    by 0x455795D: OGRFeature::SetField(int, char const*) (ogrfeature.cpp:1844)
==30842==    by 0x4415B8A: ILI1Reader::ReadTable() (ili1reader.cpp:563)
==30842==    by 0x4416773: ILI1Reader::ReadFeatures() (ili1reader.cpp:322)
==30842==    by 0x44D388F: OGRILI1DataSource::Open(char const*, int) (ogrili1datasource.cpp:156)
==30842==    by 0x44D3EE4: OGRILI1Driver::Open(char const*, int) (ogrili1driver.cpp:65)
==30842==    by 0x45005E5: OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) (ogrsfdriverregistrar.cpp:204)
==30842==    by 0x8049FB0: main (ogrinfo.cpp:149)
==30842==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==30842==
==30842== Process terminating with default action of signal 11 (SIGSEGV)
==30842==  Access not within mapped region at address 0x0
==30842==    at 0x4497001: OGRFeature::IsFieldSet(int) const (ogr_feature.h:195)
==30842==    by 0x455795D: OGRFeature::SetField(int, char const*) (ogrfeature.cpp:1844)
==30842==    by 0x4415B8A: ILI1Reader::ReadTable() (ili1reader.cpp:563)
==30842==    by 0x4416773: ILI1Reader::ReadFeatures() (ili1reader.cpp:322)
==30842==    by 0x44D388F: OGRILI1DataSource::Open(char const*, int) (ogrili1datasource.cpp:156)
==30842==    by 0x44D3EE4: OGRILI1Driver::Open(char const*, int) (ogrili1driver.cpp:65)
==30842==    by 0x45005E5: OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) (ogrsfdriverregistrar.cpp:204)
==30842==    by 0x8049FB0: main (ogrinfo.cpp:149)
==30842==
==30842== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 103 from 1)
==30842== malloc/free: in use at exit: 9,108 bytes in 105 blocks.
==30842== malloc/free: 810 allocs, 705 frees, 277,762 bytes allocated.
==30842== For counts of detected errors, rerun with: -v
==30842== searching for pointers to 105 not-freed blocks.
==30842== checked 2,293,432 bytes.
==30842==
==30842== LEAK SUMMARY:
==30842==    definitely lost: 52 bytes in 4 blocks.
==30842==      possibly lost: 458 bytes in 14 blocks.
==30842==    still reachable: 8,598 bytes in 87 blocks.
==30842==         suppressed: 0 bytes in 0 blocks.
==30842== Rerun with --leak-check=full to see details of leaked memory.
Erreur de segmentation (core dumped)

comment:2 Changed 11 years ago by warmerdam

Cc: warmerdam added
Owner: changed from warmerdam to pka

Pirmin,

What are your thoughts?

comment:3 Changed 11 years ago by Even Rouault

Fixed in trunk in r13716 and in branches/1.5 in r13717. Frank, do you think it's worth backporting in branches/1.4 (should be pretty trivial to do if the driver hasn't change a lot) ?

Otherwise, I've looked at the code a bit and, at first glance, I can see many memory leaks (confirmed by Valgrid) and a few scary things too (*). I may commit a few fixes for that just in trunk.

(*) being :

              fieldDef = new OGRFieldDefn(CPLStrdup("Field00"), OFTString);
              *(char *)(fieldDef->GetNameRef()+strlen(fieldDef->GetNameRef())-2) = '0'+fIndex/10;
              *(char *)(fieldDef->GetNameRef()+strlen(fieldDef->GetNameRef())-1) = '0'+fIndex%10;

comment:4 Changed 11 years ago by warmerdam

I don't feel strongly about back porting to 1.4.x.

I'll leave discussion of leaks and other issues between you and Pirmin.

comment:5 Changed 11 years ago by Even Rouault

Milestone: 1.5.1
Resolution: fixed
Status: newclosed

Patch for leaks and other issues provided in #2203.

Closing this bug as far as the crash is concerned

Note: See TracTickets for help on using tickets.