Getting malloc errors with grdimage of GeoTIFF in oblique Mercator projection(-JOa)

Hi, I am getting a malloc error and crash when plotting a GeoTIFF with grdimage in an oblique Mercator projection using -JOa (classic mode, GMT 6.4.0_0c12c73_2022.01.17). The same image plots just fine in other projections (e.g. -JQ), and my commands work with other modules like pscoast, psxy, pscmeca, etc so I don’t think it’s a problem with my -R or -J format. As always, thanks for any help and I’m happy to provide more details if needed.

kmbp:~ kylebradley$ gmt grdinfo colored_relief.tif
colored_relief.tif: Title: Grid imported via GDAL
colored_relief.tif: Command:
colored_relief.tif: Remark:
colored_relief.tif: Pixel node registration used [Geographic grid]
colored_relief.tif: Grid file format: gd = Import/export through GDAL
colored_relief.tif: x_min: 154.975 x_max: 159.025 x_inc: 0.00833333333333 (30 sec) name: x n_columns: 486
colored_relief.tif: y_min: -9.71666666667 y_max: -6.275 y_inc: 0.00833333333333 (30 sec) name: y n_rows: 413
colored_relief.tif: v_min: 1.79769313486e+308 v_max: -1.79769313486e+308 name: z
colored_relief.tif: scale_factor: 1 add_offset: 0
colored_relief.tif: Default CPT:
+proj=longlat +datum=WGS84 +no_defs

kmbp:~ kylebradley$ gmt grdimage colored_relief.tif -R155/159/-10/-6 -JQ155/7i -Bxaf -Byaf > testimg.ps
Successfully plots the image

kmbp:~ kylebradley$ gmt grdimage colored_relief.tif -R-200/200/-100/100+uk -JOa157/-8/122/7i -Bxaf -Byaf > testimg.ps
gmt(32334,0x110f47dc0) malloc: can’t allocate region
:*** mach_vm_map(size=18446744073709535232, flags: 100) failed (error code=3)
gmt(32334,0x110f47dc0) malloc: *** set a breakpoint in malloc_error_break to debug
grdimage [ERROR]: gdalread: failure to allocate enough memory
grdimage [ERROR]: ERROR reading image with gdalread.
grdimage (gmtapi_import_image): Could not read from file [colored_relief.tif]
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)

Using a different form of -R also doesn’t work:

kmbp:~ kylebradley$ gmt grdimage colored_relief.tif -R155/-7.8/159/-8.2+r -JOa157/-8/122/7i -Bxaf -Byaf > testimg.ps
gmt(32400,0x10cfd2dc0) malloc: can’t allocate region
:*** mach_vm_map(size=18446744073709531136, flags: 100) failed (error code=3)
gmt(32400,0x10cfd2dc0) malloc: *** set a breakpoint in malloc_error_break to debug
grdimage [ERROR]: gdalread: failure to allocate enough memory
grdimage [ERROR]: ERROR reading image with gdalread.
grdimage (gmtapi_import_image): Could not read from file [colored_relief.tif]
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)

If I convert the TIFF to netCDF using grdconvert, I can plot the result just fine:
kmbp:~ kylebradley$ gmt grdconvert colored_relief.tif colored_relief.nc
kmbp:~ kylebradley$ gmt grdimage colored_relief.nc -R-200/200/-100/100+uk -JOa157/-8/122/7i -Bxaf -Byaf > testimg.ps
Success but the image isn’t useful as it’s only one band of the TIFF.

colored_relief.tif (528.8 KB)

Hello kyleedwardbradley.

It was a bug that was fixed by Paul and just merge into master.

Great! I have recompiled and can verify that the oblique Mercator plots are working for me now. Thanks again for the quick fix, always appreciated!