#1674 closed defect (fixed)
GetDriver method of newly opened Datasource segfaults
Reported by: | Ari Jolma | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.4.2 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | mem |
Cc: | hobu |
Description (last modified by )
Code like:
use Geo::GDAL; #$driver = Geo::OGR::GetDriverByName('Memory'); $driver = Geo::OGR::GetDriverByName('Esri Shapefile'); $datasource = $driver->CreateDataSource('x'); $datasource->GetDriver;
causes a segafault:
with Memory driver:
#0 0x001aa473 in strlen () from /lib/libc.so.6 #1 0x0105b3f8 in CPLStat () from /usr/local/lib/libgdal.so.1 #2 0x0111981a in OGRShapeDataSource::Open () from /usr/local/lib/libgdal.so.1 #3 0x0111a7c6 in OGRShapeDriver::Open () from /usr/local/lib/libgdal.so.1 #4 0x01118a5d in OGRSFDriverRegistrar::Open () from /usr/local/lib/libgdal.so.1 #5 0x01118d97 in OGROpen () from /usr/local/lib/libgdal.so.1 #6 0x00720f8c in _wrap_DataSource_GetDriver (my_perl=0x9167008, cv=0x9284930) at ogr_wrap.cpp:1788
with Shapefile driver:
#0 0x01025562 in OGRSFDriverRegistrar::ReleaseDataSource () from /usr/local/lib/libgdal.so.1 #1 0x010259cc in OGRReleaseDataSource () from /usr/local/lib/libgdal.so.1 #2 0x00884f94 in _wrap_DataSource_GetDriver (my_perl=0x9eb6008, cv=0x9fd3930) at ogr_wrap.cpp:1789
The problem does not appear if the datasource is opened, not created.
Change History (4)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Cc: | added |
---|---|
Component: | default → OGR_SF |
Keywords: | mem added |
Milestone: | → 1.4.2 |
Status: | new → assigned |
On review, the problem is that the OGRMemDataSource does not record it's name. So OGR_DS_GetName() returns NULL which is passed to the open and subsequently to the CPLStat() function.
I am correcting this in trunk and 1.4 branch.
The issue is specific to the MEM driver, and not particularly to the GetDriver() method.
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
It turns out there was two problems. One was that the MEM driver did not record it's datasource name. The other was that ogr.i's GetDriver() attempted to release the datasource even if it was NULL.
One correction is in gdal/ogr/ogrsf_frmts/mem/ogrmemdatasource.cpp.
The other in gdal/swig/include/ogr.i
Both done in trunk and 1.4 branch.
comment:4 by , 17 years ago
Description: | modified (diff) |
---|
The following Python provokes it as well... Is this just incorrect usage? Even though, it shouldn't cause a segfault, I suppose.