Opened 8 years ago
Closed 8 years ago
#6585 closed defect (wontfix)
SegFault
Reported by: | aFuerst | Owned by: | hobu |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | PythonBindings | Version: | 2.1.0 |
Severity: | normal | Keywords: | |
Cc: |
Description
I'm opening a geotif file in a function call and setting it's raster band to an instance variable in a class. Later when trying to access data from the raster in another function, it throws a segfault and kills the program
Attachments (1)
Change History (2)
by , 8 years ago
comment:1 by , 8 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
You're running into one of the gotchas explained in https://trac.osgeo.org/gdal/wiki/PythonGotchas
The issue is in
def _openFile(self): f = gdal.Open(self.file_name) self.open_file = f.GetRasterBand(1)
Basically as soon as this function returns the dataset is closed because no Python object retains a reference to it, so the self.open_file points to a defunct C++ object. Workaround: maintain the reference to f alive while you work on the band object
Contains the code I'm working with and experiencing the error