[R-sig-Geo] spgrass causes segfault

Roger Bivand Roger.Bivand at nhh.no
Thu Jul 23 14:56:38 CEST 2009


On Thu, 23 Jul 2009, Dominik.Cullmann at Forst.bwl.de wrote:

> Dear Roger,
> thanks a lot for your immedate help!
>> -----Ursprüngliche Nachricht-----
>> Von: Roger Bivand [mailto:Roger.Bivand at nhh.no]
>> Gesendet: Donnerstag, 23. Juli 2009 12:53
>> An: Cullmann, Dominik (FORST)
>> Cc: r-sig-geo at stat.math.ethz.ch
>> Betreff: Re: [R-sig-Geo] spgrass causes segfault
>>
>> On Thu, 23 Jul 2009, Dominik.Cullmann at Forst.bwl.de wrote:
>>
>>> Dear all, when I call readRAST6 or readVECT6, it causes a segfault and 
>>> gives Traceback Info I don't understand:
>>
>> Thanks for the traceback information, and for including the verbatim 
>> command that caused the problem. Next time, please include 
>> sessionInfo() output too, and in this case, also the loading messages 
>> from rgdal and spgrass6. Here, it would also have helped to see what 
>> gdalDrivers() said.
> I had given that information at the end of the original mail but I'll
> repeat it, see below.
>
>>
>> I suspect that you are in "dependency hell", and that your system has a 
>> wrongly installed GDAL plugin for GRASS rasters and vectors. Please 
>> read the manual pages for readVECT6() and readRAST6() - you will see 
>> that if the plugin= argument is not given (NULL), the documentation 
>> says that the presence (or not) of the plugin is autodetected (by 
>> looking at ogrDrivers() and gdalDrivers()).
>>
>> Unless you know definitely that the plugin does work (and it is the 
>> most frequent cause of dependency problems), please try setting 
>> plugin=FALSE in readRAST6() and readVECT6().
> This works:

Good, some progress.

>>   require(spgrass6)
> Loading required package: spgrass6
> Loading required package: sp
> Loading required package: rgdal
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.5.4, released 2009/01/07
> Path to GDAL shared files: /usr/share/gdal15
> Loaded PROJ.4 runtime: Rel. 4.6.0, 21 Dec 2007
> Path to PROJ.4 shared files: (autodetected)
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: 6.4.0RC5
> and location: spearfish60
>>   sessionInfo()
> R version 2.9.1 (2009-06-26)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] spgrass6_0.6-6 XML_2.5-3      rgdal_0.6-9    sp_0.9-43
>

There is a newer rgdal, but I don't think that it will affect the raster 
interface.

> loaded via a namespace (and not attached):
> [1] grid_2.9.1      lattice_0.17-25
>>   tmp <- readRAST6("geology", plugin=FALSE)
> /home/data/grass/spearfish60/PERMANENT/.tmp/f060/geology has GDAL driver GTiff
> and has 140 rows and 190 columns
>
>
>> If that resolves the problem, please then try to see what happens when 
>> gdalinfo used outside R tries to access the GRASS raster using the 
>> plugin, see http://www.gdal.org/frmt_grass.html for the incantation. If 
>> that fails, then you will know that the problem is with the GDAL GRASS 
>> plugin.
> Well, gdalinfo seems to work fine:

So it does read the metadata, so the problem must be in the data itself. 
Is it possible that you have binary GDAL 1.5.4, the binary GDAL GRASS 
plugin from GDAL 1.5.2 (so built against an oldish Debian GRASS), and 
GRASS not binary, but built from source, as you detail below, with 
--enable-largefile (which may or may not make a difference). This means 
that the plugin looks for GRASS, and finds some ABI compoments that work, 
but others that fail? The GDAL plugin were not build against your local 
GRASS, and are trying to use its shared objects (*.so files).

To straighten things out, you'd need either to install the binary GRASS 
that matches the plugin exactly, or install GDAL twice from source, first 
configuring without GRASS, then building GRASS, finally rebuilding GDAL 
pointing at the new GRASS to build the plugin. It could be simpler, 
really. Using plugin=FALSE saves the pain, although the raster plugin does 
move data faster in some settings, and the vector one does when there are 
few attributes.

Roger

>
> 101:~/$ gdalinfo /home/data/grass/spearfish60/PERMANENT/cellhd/geology
> Driver: GRASS/GRASS Database Rasters (5.7+)
> Files: /home/data/grass/spearfish60/PERMANENT/cellhd/geology
> Size is 190, 140
> Coordinate System is `'
> Origin = (590000.000000000000000,4928000.000000000000000)
> Pixel Size = (100.000000000000000,-100.000000000000000)
> Corner Coordinates:
> Upper Left  (  590000.000, 4928000.000)
> Lower Left  (  590000.000, 4914000.000)
> Upper Right (  609000.000, 4928000.000)
> Lower Right (  609000.000, 4914000.000)
> Center      (  599500.000, 4921000.000)
> Band 1 Block=190x1 Type=Byte, ColorInterp=Palette
>  Min=1.000 Max=9.000
>  NoData Value=0
>  Metadata:
>    COLOR_TABLE_RULES_COUNT=0
>  Color Table (RGB with 10 entries)
>    0: 197,129,125,255
>    1: 107,250,75,255
>    2: 226,83,250,255
>    3: 246,222,188,255
>    4: 123,225,27,255
>    5: 134,190,1,255
>    6: 48,86,221,255
>    7: 113,70,15,255
>    8: 102,134,101,255
>    9: 89,135,169,255
>
>>
>> If this isn't the cause, I'd like an example using spearfish and with
>> complete details of your GRASS and GDAL installations.
>>
> The example I gave was on the 'geology' raster from the spearfish60 data set.
> I had given installation details at the end of the original mail:
>
> 104:~/$ cat /etc/debian_version 5.0.2 105:~/$ uname -a Linux f060 
> 2.6.26-2-686 #1 SMP Sun Jun 21 04:57:38 UTC 2009 i686 GNU/Linux 106:~/$ 
> dpkg -l |grep gdal ii gdal-bin 1.5.4-2 Geospatial Data Abstraction 
> Library - Utility programs ii libgdal1-1.5.0 1.5.4-2 Geospatial Data 
> Abstraction Library ii libgdal1-1.5.0-grass 1.5.2-1 GRASS extension for 
> the Geospatial Data Abstraction Library ii libgdal1-dev 1.5.4-2 
> Geospatial Data Abstraction Library - Development files 115:~/$ dpkg -l 
> |grep "Cartographic projection" ii proj 4.6.0-2 Cartographic projection 
> filter and library ... oh, and I'm using grass version 6.4.0RC5 which I 
> compiled after configuring via CFLAGS="-g -Wall" ./configure 
> --with-opengl=no --with-tcltk-libs=/usr.lib 
> --with-tcltk-includes='/usr/include/tcl8.4/ /usr/include/tk/' 
> --with-tcltk-libs='/usr/lib/tcl8.4/' --with-odbc=yes 
> --with-fftw-libs='/usr/include' -with-gdal='/usr/bin/gdal-config' 
> --with-postgres=yes --with-postgres-includes='/usr/include/postgresql/' 
> --enable-largefile --with-lapack=yes --with-blas=yes
>
>
>
>> The stats-grass list would also have been a good place to ask - its
>> archives show that happy plugin users are most often those who build
>> everything from source, and unhappy ones those who install binary
>> versions. It is extremely hard to make sure that all the binary
>> versions of the dependent software are correctly alligned
>> (and there is a
>> possible circular dependency here too in older versions of GRASS and
>> GDAL).
>>
>> Hope this helps,
> Yes, it does. Thanks again,
> Dominik
>
>>
>> Roger
>>
>>> =======
>>>> tmp<-readRAST6("geology")
>>>
>>> *** caught segfault ***
>>> address (nil), cause 'memory not mapped'
>>>
>>> Traceback:
>>> 1: .Call("RGDAL_OpenDataset", as.character(filename), TRUE,
>> PACKAGE =
>>> "rgdal")
>>> 2: .local(.Object, ...)
>>> 3: initialize(value, ...)
>>> 4: initialize(value, ...)
>>> 5: new("GDALReadOnlyDataset", filename)
>>> 6: GDAL.open(fname)
>>> 7: GDALinfo(fname)
>>> 8: readRAST6("geology")
>>>
>>> Possible actions:
>>> 1: abort (with core dump, if enabled)
>>> 2: normal R exit
>>> 3: exit R without saving workspace
>>> 4: exit R saving workspace
>>> =======
>>> Can anybody 'round here give me a hint on how I might get
>> this working?
>>>
>>> I'm using R version 2.9.1 (2009-06-26) from backports on
>> Debian stable:
>>> =======
>>> ======= some system info
>>> =======
>>> 104:~/$ cat /etc/debian_version
>>> 5.0.2
>>> 105:~/$ uname -a
>>> Linux f060 2.6.26-2-686 #1 SMP Sun Jun 21 04:57:38 UTC 2009 i686
>>> GNU/Linux
>>> 106:~/$ dpkg -l |grep gdal
>>> ii  gdal-bin                             1.5.4-2    Geospatial Data
>>> Abstraction Library - Utility programs
>>> ii  libgdal1-1.5.0                       1.5.4-2    Geospatial Data
>>> Abstraction Library
>>> ii  libgdal1-1.5.0-grass                 1.5.2-1    GRASS
>> extension for
>>> the Geospatial Data Abstraction Library
>>> ii  libgdal1-dev                         1.5.4-2    Geospatial Data
>>> Abstraction Library - Development files
>>> 115:~/$ dpkg -l |grep "Cartographic projection"
>>> ii  proj                                 4.6.0-2    Cartographic
>>> projection filter and library
>>>
>>> =======
>>> ======= Now after I started R form within grass
>>> =======
>>>> library(spgrass6)
>>> Loading required package: sp
>>> Loading required package: rgdal
>>> Geospatial Data Abstraction Library extensions to R
>> successfully loaded
>>> Loaded GDAL runtime: GDAL 1.5.4, released 2009/01/07
>>> Path to GDAL shared files: /usr/share/gdal15
>>> Loaded PROJ.4 runtime: Rel. 4.6.0, 21 Dec 2007
>>> Path to PROJ.4 shared files: (autodetected)
>>> Loading required package: XML
>>> GRASS GIS interface loaded with GRASS version: 6.4.0RC5
>>> and location: spearfish60
>>>> sessionInfo()
>>> R version 2.9.1 (2009-06-26)
>>> i486-pc-linux-gnu
>>>
>>> locale:
>>>
>> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLA
>> TE=en_US.U
>>>
>> TF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-
>> 8;LC_NAME=
>>>
>> C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_ID
>> ENTIFICATI
>>> ON=C
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] spgrass6_0.6-6 XML_2.5-3      rgdal_0.6-9    sp_0.9-43
>>>
>>> loaded via a namespace (and not attached):
>>> [1] grid_2.9.1      lattice_0.17-25
>>>> tmp<-readRAST6("geology")
>>>
>>> *** caught segfault ***
>>> address (nil), cause 'memory not mapped'
>>>
>>> Traceback:
>>> 1: .Call("RGDAL_OpenDataset", as.character(filename), TRUE,
>> PACKAGE =
>>> "rgdal")
>>> 2: .local(.Object, ...)
>>> 3: initialize(value, ...)
>>> 4: initialize(value, ...)
>>> 5: new("GDALReadOnlyDataset", filename)
>>> 6: GDAL.open(fname)
>>> 7: GDALinfo(fname)
>>> 8: readRAST6("geology")
>>>
>>> Possible actions:
>>> 1: abort (with core dump, if enabled)
>>> 2: normal R exit
>>> 3: exit R without saving workspace
>>> 4: exit R saving workspace
>>> =======
>>> =======
>>> =======
>>> oh, and I'm using grass version 6.4.0RC5 which I compiled after
>>> configuring via
>>> CFLAGS="-g -Wall" ./configure   --with-opengl=no
>>> --with-tcltk-libs=/usr.lib
>> --with-tcltk-includes='/usr/include/tcl8.4/
>>> /usr/include/tk/' --with-tcltk-libs='/usr/lib/tcl8.4/'
>> --with-odbc=yes
>>> --with-fftw-libs='/usr/include' -with-gdal='/usr/bin/gdal-config'
>>> --with-postgres=yes
>> --with-postgres-includes='/usr/include/postgresql/'
>>> --enable-largefile --with-lapack=yes --with-blas=yes
>>>
>>>
>>> Thanks and regards, Dominik
>>> ----------------------------------------------
>>> Andreas Dominik Cullmann
>>> Forstliche Versuchs- und Forschungsanstalt
>>> Wonnhalde 4
>>> 79100 Freiburg
>>> Tel. +49 761 4018 204
>>> Email: dominik.cullmann at forst.bwl.de
>>> <mailto:dominik.cullmann at forst.bwl.de>
>>> Homepage: www.fva-bw.de <http://www.fva-bw.de>
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> Roger Bivand
>> Economic Geography Section, Department of Economics,
>> Norwegian School of
>> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
>> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
>> e-mail: Roger.Bivand at nhh.no
>>
>>
>
>
> ----------------------------------------------
> Andreas Dominik Cullmann
> Forstliche Versuchs- und Forschungsanstalt
> Wonnhalde 4
> 79100 Freiburg
> Tel. +49 761 4018 204
> Email: dominik.cullmann at forst.bwl.de <mailto:dominik.cullmann at forst.bwl.de>
> Homepage: www.fva-bw.de <http://www.fva-bw.de>
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list