Bug report #19252

GDAL crash in QGIS only when saving a new raster

Added by Andrew Blakey almost 6 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:GDAL Tools
Affected QGIS version:3.1(master) Regression?:No
Operating System:16.04 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27080

Description

When I attempt to run a snippet of code in QGIS's Python window that creates a GeoTiff, it crashes QGIS. If I run the same in Python 3.5.2 from the cli with the same dependencies it completes fine and creates the GeoTiff. Any suggestions on how to further debug this would be appreciated.

import gdal, numpy

print(numpy.version.version)  # 1.14.5
print(gdal.VersionInfo())  # 2020200

gdal.UseExceptions()

data = numpy.zeros((100, 100), numpy.int8)

driver = gdal.GetDriverByName('GTiff')
outRaster = driver.Create('/tmp/output.tif', 100, 100, 1, gdal.GDT_Byte)
outRaster.SetGeoTransform((0, 0.05, 0, 0, 0, 0.05))
outBand = outRaster.GetRasterBand(1)
outBand.WriteArray(data)
outRaster = None

One of these three things is printed when the crash occurs

ERROR 4: Unable to open /tmp/output.tif to obtain file list.
QGIS died on signal 11

or

*** Error in `/usr/bin/qgis.bin': malloc(): memory corruption: 0x0000562f2bcce480 ***

or

Traceback (most recent call last):
  File "/usr/lib/python3.5/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 453, in Create
    return _gdal.Driver_Create(self, *args, **kwargs)
RuntimeError: Unable to open /tmp/output.tif to obtain file list.

Also available in: Atom PDF