Skip to content

Bands get cleared after attribute table creation fails, causing rendering issues and crashes #65040

Description

@ashduino101

What is the bug or the crash?

When creating an attribute table that's managed by the data provider on a COG raster layer, it fails with the message "GDAL error saving raster attribute table, raster attribute table could not be saved." (this might not be true of all COG layers, but that's a separate issue). This causes the list of bands to be reset, and occasionally logs the error "ERROR 10: Pointer 'hBand' is NULL in 'GDALSetDefaultRAT'." to the console. More importantly, it causes the layer to render extremely strangely, and almost looks to be reading image data from somewhere else in the program memory. See attached video for an example.

I also encountered a crash in QgsRasterLayerProperties::sync after the bands were reset, but I can't seem to reproduce it.
It's also worth noting that this does not happen with GeoTIFF layers, only COG layers.

MRE COG file:
cog_vat_bug_sample.tif

Video:
https://github.com/user-attachments/assets/43d4475f-a652-4652-8f45-dcc03dd9e25b

Steps to reproduce the issue

  1. Create a raster layer from a COG TIFF file
  2. Open the properties, go to "Attribute Tables", and click "New attribute table from current symbology"
  3. Observe the GDAL error, and click OK
  4. Try to create the attribute table again, this time using a sidecar VAT.DBF file
  5. This should work, now click OK
  6. Observe that the band list is now empty, and panning/zooming the map causes weird artifacts and visible corruption/memory issues

Versions

QGIS version3.44.7-Solothurn
QGIS code branchRelease 3.44
 
Libraries
Qt version5.15.18
Python version3.14.2
GDAL version3.11.5 — Eganville
PROJ version9.6.2
EPSG Registry database versionv12.013 (2025-05-26)
GEOS version3.14.1-CAPI-1.20.5
SQLite version3.50.2
PDAL version2.9.3
PostgreSQL client version18.0
SpatiaLite version5.1.0
QWT version6.2.0
QScintilla2 version2.14.1
OS versionFedora Linux 43 (KDE Plasma Desktop Edition)
 
Active Python plugins
loadthemall3.4
advanced_map_downloader1.0.0
xyz_tiles_basemap_loader0.1
ee_plugin0.1.7
vrtbuilderplugin0.9.20210222T174536.master
shapefile_encoding_fixer0.7.1
processing_saga_nextgen1.1.0
wbt_for_qgis1.0.9
a00_qpip1.4.2
qraster_merge1.0.1
MetaSearch0.3.6
db_manager0.1.20
grassprovider2.12.99
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

I could reproduce this on both the Wayland and X11 QT platforms

Metadata

Metadata

Assignees

Labels

BugEither a bug report, or a bug fix. Let's hope for the latter!RastersRelated to general raster layer handling (not specific data formats)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions