-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GTiff: segmentation fault building overviews for Float32 #2946
Comments
Can you attach a sample input file demonstrating the issue ? I can't replicate that with regular Float32 TIFF files. I believe the root cause might be GRASS attaches a ColorMap to a Float32 TIFF which is quite unusual. |
GRASS tries to attach a color map independent of the datatype unless the user suppresses writing color rules with |
it shouldn't. As far as I can see the GDAL GTiff driver only allows to create a color map for Byte and UInt16 data type, which makes sense (actually reading the TIFF6 spec, colormaps should only be used for 4-bit or 8-bit data...). But perhaps I'm missing a code path that would still allow that. |
In contrast to the GTiff driver, the COG driver only supports |
Minimum reproducer found with your above indications from osgeo import gdal
src_ds = gdal.GetDriverByName('MEM').Create('', 1000,1000,1,gdal.GDT_Float32)
ct = gdal.ColorTable()
src_ds.GetRasterBand(1).SetColorTable(ct)
gdal.GetDriverByName('COG').CreateCopy('/vsimem/my.cog.tif', src_ds) # segfault |
This PR removes the `r.out.gdal -c` workaround due to a former color table export bug in GDAL COG export (OSGeo/gdal#2946). It was fixed in GDAL 3.1.4.
This PR removes the `r.out.gdal -c` workaround due to a former color table export bug in GDAL COG export (OSGeo/gdal#2946). It was fixed in GDAL 3.1.4.
Expected behavior and actual behavior.
Expected:
Creating a COG of datatype Float32 works, and building overviews for a GTiff of datatype Float32 works.
Problem:
Segmentation fault at https://github.com/OSGeo/gdal/blob/master/gdal/frmts/gtiff/libtiff/tif_dirwrite.c#L2064 because
tif->tif_dir.td_colormap[0]
is NULL.This segmentation fault occurs e.g. with COG when building overviews calling
GTIFFBuildOverviewsEx()
.Creating COG files of datatype Byte works just fine, there must be a problem with datatype Float32.
I am not familiar with the GDAL-internal libtiff. Any hints on the problem
tif->tif_dir.td_colormap[0]
for Float32 that could help me to produce a reasonable PR?Steps to reproduce the problem.
Alternative:
use
gdal_translate -of COG
with any raster dataset with datatype Float32Original problem:
In GRASS GIS, using the North Carolina sample dataset:
Operating system
Fedora 32, Ubuntu ?
GDAL version and provenance
GDAL 3.1.3 compiled from source, also other GDAL 3.1.? versions on other operating systems
The text was updated successfully, but these errors were encountered: