Opened 16 years ago

Closed 16 years ago

#1910 closed defect (duplicate)

python ogr.Open segfaults with None as name

Reported by: timaranz Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.5.0
Component: OGR_SF Version: 1.4.3
Severity: normal Keywords: validate
Cc: hobu, warmerdam

Description

the following 2 lines will cause python to segfault:

import ogr ogr.Open(None)

It should raise a TypeError instead.

Change History (5)

comment:1 by timaranz, 16 years ago

using the swig interface

comment:2 by hobu, 16 years ago

Are you using the old-gen or the next-gen bindings?

With the next-gen bindings, I get a proper error:

>>> from osgeo import ogr
>>> ogr.UseExceptions()
>>> ogr.Open(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Users/hobu/svn/gdal/swig/python/osgeo/ogr.py", line 3143, in Open
    return _ogr.Open(*args, **kwargs)
RuntimeError: Pointer 'pszName' is NULL in 'OGROpen'.

comment:3 by warmerdam, 16 years ago

Cc: hobu warmerdam added
Component: defaultOGR_SF
Keywords: validate added
Milestone: 1.5.0
Owner: changed from warmerdam to Mateusz Łoskot
Version: unspecifiedsvn-trunk

With the NG trunk bindings I get an induced crash (when not using UseExceptions):

(gdb) where 5
#0  0x00002aaaab09513d in raise () from /lib/libc.so.6
#1  0x00002aaaab09686e in abort () from /lib/libc.so.6
#2  0x00002aaaabecd96f in CPLErrorV (eErrClass=CE_Fatal, err_no=10, 
    fmt=0x2aaaac28a248 "Pointer '%s' is NULL in '%s'.\n", args=0x7ffffffe9d80)
    at cpl_error.cpp:208
#3  0x00002aaaabecd774 in CPLError (eErrClass=CE_Fatal, err_no=10, 
    fmt=0x2aaaac28a248 "Pointer '%s' is NULL in '%s'.\n") at cpl_error.cpp:133
#4  0x00002aaaac017d28 in OGROpen (pszName=0x0, bUpdate=0, pahDriverList=0x0)
    at ogrsfdriverregistrar.cpp:201
(More stack frames follow...)
(gdb) 

It appears the VALIDATE macro in effect is issuing a fatal, error rather than a CE_Failure error. I don't know why. Turning over to Mateusz to address since he did the validation stuff.

comment:4 by hobu, 16 years ago

Tim,

The CE_Fatal error is thrown because you've built GDAL in debug mode. CE_Failure is thrown when non-debug builds are made. See #1602 for more details.

Howard

comment:5 by timaranz, 16 years ago

Resolution: duplicate
Status: newclosed
Version: svn-trunk1.4.3

I have finally figured out that all the validation stuff you are talking about is in the trunk and I'm using the 1.4.3 branch which doesn't have any validation.

So AFAICT the bug is fixed in the trunk (duplicate of 1602) and all I need to do is wait for 1.5 to come out.

Note: See TracTickets for help on using tickets.