[GRASS5] Re: [Pkg-grass-general] Re: gdal and grass

> > one of GRASS commands does not work. I suspect this is due to gdal
> > packaging: ==========================================
> > r.out.gdal input=t_dtm@PERMANENT format=GTiff
> > type=Byte output=/home/daniela/prova
> > Writing format: GTiff
> > Writing type: Byte
> > /usr/lib/grass/scripts/r.out.gdal: line 129:
> > 6156 Segmentation fault gdal_translate -of
> > $FORMAT -ot $TYPE -a_srs "`g.proj -wf`"
> > $CREATEKEY $METAKEY $CELLHD $OUTPUT
>
> Ah, a segfault. A gdb backtrace and the output when running this
> command in valgrind would be helpful for those trying to debug this
> problem. I have no knowledge about gdal so I can't really help here,
> but recommend trying to get more debug output out of the crashing
> program.

Hi, I've now got the DebianGIS alioth packages installed on a test
machine and can provide some more debug info...

gdal_translate SegFault reproduced here..

r.out.gdal is a script; line 129 reads:

gdal_translate -of $FORMAT -ot $TYPE -a_srs "`g.proj -wf`" \
  $CREATEKEY $METAKEY $CELLHD $OUTPUT

I added an extra line:
echo "gdal_translate -of $FORMAT -ot $TYPE -a_srs `g.proj -wf` \
  $CREATEKEY $METAKEY $CELLHD $OUTPUT"

before actually running the command.
[paths shortened by me]

Writing format: GTiff
Writing type: Byte
gdal_translate -of GTiff -ot Byte -a_srs PROJCS["New Zealand Map Grid",GEOGCS["international",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["international",6378388,297]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["New_Zealand_Map_Grid"],PARAMETER["latitude_of_origin",-41],PARAMETER["central_meridian",173],PARAMETER["false_easting",2510000],PARAMETER["false_northing",6023150],UNIT["metre",1]] /path/to/cellhd/tm24r_b6 tm6_test2
/usr/lib/grass/scripts/r.out.gdal: line 132: 29221 Segmentation fault gdal_translate -of $FORMAT -ot $TYPE -a_srs "`g.proj -wf`" $CREATEKEY $METAKEY $CELLHD $OUTPUT

I tried this with on my primary devel machine (self compiled grass 6beta2)
and still get an error, although slightly different:

Writing format: GTiff
Writing type: Byte
gdal_translate -of GTiff -ot Byte -a_srs PROJCS["New Zealand Map Grid",GEOGCS["international",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["international",6378388,297]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["New_Zealand_Map_Grid"],PARAMETER["latitude_of_origin",-41],PARAMETER["central_meridian",173],PARAMETER["false_easting",2510000],PARAMETER["false_northing",6023150],UNIT["meter",1]] /path/to/cellhd/tm24r_b6 tm6_test4
ERROR 4: `/path/to/cellhd/tm24r_b6' not recognised as a supported file format.

GDALOpen failed - 4
`/path/to/cellhd/tm24r_b6' not recognised as a supported file format.

now, GRASS is not listed as a plugin from 'gdal_translate --help'

Frank Warmerdam on 28 Jan wrote:
  "gdal_translate only lists writable formats."

The libgdal1-grass 1.2.5-0.dgis.unstable.1 package is installed.
(/usr/lib/gdal_GRASS.so exists)

[test machine with libgdal1-grass installed]
gdalinfo --formats | grep -i GRASS
  GRASS (ro): GRASS Database Rasters (5.7+)

[on my primary devel machine the plugin isn't installed & isn't found]

modifying the (packaged) r.out.gdal some more to run gdal_translate
through the debugger:

...
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 29273)]
0x40fa539a in G_find_cell2 () from /usr/lib/grass/lib/libgrass_gis.so
(gdb) bt
#0 0x40fa539a in G_find_cell2 () from /usr/lib/grass/lib/libgrass_gis.so
#1 0x40fa5576 in G_find_file () from /usr/lib/grass/lib/libgrass_gis.so
#2 0x40fa5330 in G_find_cell () from /usr/lib/grass/lib/libgrass_gis.so
#3 0x40fb60af in G_raster_map_type () from /usr/lib/grass/lib/libgrass_gis.so
#4 0x4001b64f in GRASSRasterBand::GRASSRasterBand () from /usr/lib/gdal_GRASS.so
#5 0x00000000 in ?? ()
#6 0x4141d8d9 in ?? ()
#7 0x00000000 in ?? ()
#8 0x414013eb in ?? ()
#9 0x00000000 in ?? ()
#10 0x3ff00000 in ?? ()
#11 0x00000000 in ?? ()
#12 0x00000000 in ?? ()
#13 0x02987449 in ?? ()
#14 0x4004c154 in ?? () from /usr/lib/libgdal.so.1
#15 0xbffff3e4 in ?? ()
#16 0x40016f88 in ?? ()
#17 0x00000001 in ?? ()
#18 0x01000001 in ?? ()
#19 0x080564b8 in ?? ()
#20 0x00000001 in ?? ()
#21 0x40357ccc in ?? () from /usr/lib/libgdal.so.1
#22 0x01fff3e4 in ?? ()
#23 0x08055de8 in ?? ()
#24 0xbffff3c8 in ?? ()
#25 0x40194b8f in VSIRewind () from /usr/lib/libgdal.so.1
Previous frame inner to this frame (corrupt stack?)
(gdb)

very interesting.. G_find_cell2() is where QGIS segfaults when loading
a GRASS raster ...... (see next email)

Hope someone can make some sense of all this.

Hamish