Skip to content

[Bug] r.out.gdal: export of COG and GPKG fails with segfault #6398

@ninsbl

Description

@ninsbl

Describe the bug

r.out.gdal runs into a segmentation fault, when exporting raster data to COG or GPKG. The problem is likely that these formats are not written directly but go through the memory driver.
The issue is seemingly not triggered if nodata and data type checks are skipped.

After some debuging it looks to me that the issue is related to the new PARSON library (see valgrind output below). However, parson is present also in the 8.4 release branch and there COG export works...

To reproduce

valgrind --leak-check=full --track-origins=yes -s r.out.gdal input=aspect output=/tmp/test_raster.tif format=COG createopt="COMPRESS=LZW" overviews=2 --o --q

Expected behavior

COG and GPKG are quite central formats and should work without issues.

System description

  • Operating System: Linux [Ubuntu 22.04, Fedora 42]
  • GRASS version: 8.5

Additional context

Here is a piece of valgrind output from debuging the issue:

==282957== 1 errors in context 1 of 67:
==282957== Invalid read of size 8
==282957==    at 0x6BAAD49: json_object_get_cell_ix (parson.c:632)
==282957==    by 0x6BAB04A: json_object_getn_value (parson.c:698)
==282957==    by 0x6BAE2FB: json_object_get_value (parson.c:1629)
==282957==    by 0x6BAE320: json_object_get_string (parson.c:1634)
==282957==    by 0x4BC36A0: CPLJSONObject::ToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (cpl_json.cpp:1075)
==282957==    by 0x4BD39FB: CPLJSONObject::GetString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (cpl_json.cpp:1059)
==282957==    by 0x5C253B2: gdal::TileMatrixSet::parse(char const*) (tilematrixset.cpp:192)
==282957==    by 0x4E49980: GDALCOGDriver::InitializeCreationOptionList() (cogdriver.cpp:1556)
==282957==    by 0x4E289AF: GDALCOGDriver::GetMetadataItem(char const*, char const*) (cogdriver.cpp:1404)
==282957==    by 0x5AF219D: GDALValidateCreationOptions (gdaldriver.cpp:2119)
==282957==    by 0x5B0EFDA: GDALDriver::CreateCopy(char const*, GDALDataset*, int, char const* const*, int (*)(double, char const*, void*), void*) (gdaldriver.cpp:1334)
==282957==    by 0x405130: main (main.c:782)
==282957==  Address 0xdd353a9072c1a08 is not stack'd, malloc'd or (recently) free'd

Metadata

Metadata

Assignees

No one assigned

    Labels

    CRelated code is in CC++Related code is in C++blockerBlocking a releasebugSomething isn't workingrasterRelated to raster data processing

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions