[GRASS5] r.average segfault

Markus Neteler neteler at itc.it
Tue Nov 8 02:54:22 EST 2005


Brad,
(cc grass5)

great - it seems to work! This was a long standing bug
(a couple of years?). A test:

r.stats -anC input='usa_income_employment2002_states,usa_income_employment2002_avg_wages' fs=space
WARNING: r.stats: cats for usa_income_employment2002_avg_wages are either
         missing or have no explicit labels. Using nsteps=255
r.stats:  100%
2 19777.666667-19998.8 1861497713.571833
2 20662.2-20883.333333 1501426192.699261
2 21546.733333-21767.866667 1610707648.889104
2 21767.866667-21989 1595985234.376738
...
51 37026.066667-37247.2 12379878568.384022

r.average cover=usa_income_employment2002_avg_wages base=usa_income_employment2002_states out=usa_income_employment2002_states_avg_wages
WARNING: r.stats: cats for usa_income_employment2002_avg_wages are either
         missing or have no explicit labels. Using nsteps=255
r.stats:  100%
percent complete:  100%

The calculations no longer segfault.

v.univar usa_income_employment2002 col=B34_2002
WARNING: Incompatible vector type(s), only number of features, minimum,
         maximum and range can be calculated
number of features with non NULL attribute: 11954
number of missing attributes: 0
number of NULL attributes: 0
minimum: 15355
maximum: 71993
range: 56638


# note that I have zoomed before creating the raster map:
r.info -r usa_income_employment2002_avg_wages
min=15355.000000
max=71744.000000

r.info -r usa_income_employment2002_states_avg_wages
min=21639.958984
max=57480.898438

Upon first inspection the results look reasonable.

Fixes bug #2767.

Thanks, Brad!

 Markus

On Mon, Nov 07, 2005 at 04:17:05PM -0800, Brad Douglas wrote:
> I suspect that the variable 'i' has no real usage and was missed durning
> an upgrade of the file.  cvs up and let me know if you still get
> segfaults.
> 
> On Mon, 2005-11-07 at 23:37 +0100, Markus Neteler wrote:
> > Brad,
> > 
> > I just updated at home on my Mandriva 2005 box, same problem:
> > 
> > (gdb) r -anC input='usa_incemp2002_states,usa_incemp2002_avg_wages' fs=space
> > Starting program: /home/neteler/soft/61grass_cvsexp/dist.i686-pc-linux-gnu/bin/r.stats -anC input='usa_incemp2002_states,usa_incemp2002_avg_wages' fs=space
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0xb7f4dc84 in G_set_raster_cats_title (title=0xbfffea40 "usa_incemp2002_avg_wages",
> >     pcats=0xba1c36a8) at cats.c:1537
> > 1537        pcats->title = G_store (title);
> > 
> > Maybe it's the compiler flags I am using?
> > 
> > export CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common"
> > ./configure --with-cxx \
> >   --with-postgres-includes=/usr/include/pgsql \
> >   --with-gdal=/usr/local/bin/gdal-config \
> >   --with-proj \
> >   --with-motif \
> >   --with-glw \
> >   --with-nls \
> >   --with-sqlite \
> >   --with-opendwg \
> >   --with-opendwg-includes=/home/neteler/soft/openDWGtoolkit \
> >   --with-opendwg-libs=/home/neteler/soft/openDWGtoolkit \
> >   --with-freetype  --with-freetype-includes=/usr/include/freetype2 \
> >   --enable-largefile
> > 
> > I am testing on 32bit, both INTEL Pentium4 (office and laptop).
> > 
> > Markus
> > 
> > 
> > On Mon, Nov 07, 2005 at 01:10:58PM -0800, Brad Douglas wrote:
> > > Markus,
> > > 
> > > I updated CVS and ran 'r.stats -anC fields,elevation.10m' in Spearfish
> > > and it works without error (but warns that elevation.10m does not have
> > > cats).
> > > 
> > > ???
> > > 
> > > On Mon, 2005-11-07 at 09:39 +0100, Markus Neteler wrote:
> > > > Brad,
> > > > 
> > > > I tested and r.stats still crashed...
> > > > It looped over usa_income_employment2002_states, then
> > > > usa_income_employment2002_county_avg_wages, then crash in the
> > > > 'for' line. I have patched it again, taking code from
> > > > r.patch. Now it works.
> > > > 
> > > > But: The next bug appears when opening the
> > > > 'usa_income_employment2002_county_avg_wages' map. May I bother
> > > > you again? This bug can be easily reproduced in Spearfish
> > > > running:
> > > > 
> > > > r.stats -anC fields,elevation.10m
> > > > 
> > > > gdb `which r.stats`
> > > > (gdb) r -anC fields,elevation.10m
> > > > Starting program: /nfsmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/bin/r.stats -anC fields,elevation.10m
> > > > 
> > > > Program received signal SIGSEGV, Segmentation fault.
> > > > 0x004a9bec in G_set_raster_cats_title (title=0xbfeb1f00 "", pcats=0x3fa13ae0) at cats.c:1537
> > > > 1537        pcats->title = G_store (title);
> > > > 
> > > > (gdb) bt full
> > > > #0  0x004a9bec in G_set_raster_cats_title (title=0xbfeb1f00 "", pcats=0x3fa13ae0) at cats.c:1537
> > > > No locals.
> > > > #1  0x004a9afa in G_init_raster_cats (title=0xbfeb1f00 "", pcats=0x3fa13ae0) at cats.c:1488
> > > > No locals.
> > > > #2  0x004a8563 in G__read_cats (element=0x4e4c60 "cats", name=0x8fdae48 "elevation.10m", mapset=0x8fdaf78 "PERMANENT",
> > > >     pcats=0x3fa13ae0, full=1) at cats.c:488
> > > >         fd = (FILE *) 0x8fdc200
> > > >         buff = "\000\0001847 categories\000\000\000\037�0�\b�\000\024�\000H\037�aK\000DcN\000H\bx\bHaK\000/mpa\024�\000f\031?\000\fL\000p\037�000\000\000\000H\bx\bta/spearfish\001\000\000\000/mpa_gdata/ssi/BIO/GRASS_DATA/data/spearfish60/PERMANENT/fcell/elevation.10m\000\000\000\000\002\000\000\000\220N\000"...
> > > >         cat = 1682713778
> > > >         val1 = -0.84838902935116645
> > > >         val2 = 0
> > > >         old = 0
> > > >         fp_map = 1
> > > >         num = 1847
> > > > #3  0x004a824d in G_read_raster_cats (name=0x8fdae48 "elevation.10m", mapset=0x8fdaf78 "PERMANENT", pcats=0x3fa13ae0)
> > > >     at cats.c:372
> > > >         type = 0x4a8220 "U\211�\203�024�
> > > > #4  0x004a8218 in G_read_cats (name=0x8fdae48 "elevation.10m", mapset=0x8fdaf78 "PERMANENT", pcats=0x3fa13ae0) at cats.c:350
> > > > No locals.
> > > > #5  0x0804a546 in main (argc=3, argv=0xbfeb2674) at main.c:280
> > > >         msg = '\0' <repeats 44 times>, "4\a3\000\000\000\000\000�3\000\030$�\200\004\b%뿩�\0004\200\004\b\a\000\000\000\030$�003\000\000\000\t\006\002\000\236$�000\000\000"
> > > >         to_screen = 0x804bf18 " output to screen "
> > > >         fd = (int *) 0x8fdaf88
> > > >         i = 4583412
> > > >         names = (char **) 0x8fdae08
> > > >         ptr = (char **) 0x8fdae0c
> > > >         name = 0x8fdae48 "elevation.10m"
> > > >         mapset = 0x8fdaf78 "PERMANENT"
> > > >         verbose = 1
> > > >         raw_data = 0
> > > >         with_coordinates = 0
> > > >         with_xy = 0
> > > >         with_percents = 0
> > > >         with_counts = 0
> > > >         with_areas = 1
> > > >         with_labels = 0
> > > >         fmt = '\0' <repeats 19 times>
> > > >         dp = -1
> > > >         range = {min = 1, max = 63, first_time = 0}
> > > >         fp_range = {min = 4.9406564584124654e-324, max = 4.9406564584124654e-324, first_time = 0}
> > > >         q = {truncate_only = 758722102, round_only = 1160655410, defaultDRuleSet = 1886221132, defaultCRuleSet = 0,
> > > >   infiniteLeftSet = 0, infiniteRightSet = 0, cRangeSet = 0, maxNofRules = 3329843, nofRules = 134516531,
> > > >   defaultDMin = 1.0777334131618748e-307, defaultDMax = 1.525183134850258e-314, defaultCMin = -1075108572, defaultCMax = 3311161,
> > > >   infiniteDLeft = 4.8663130273591856e-270, infiniteDRight = 6.8826446699923356e-313, infiniteCLeft = 0, infiniteCRight = 0,
> > > >   dMin = 1.1461765041289974e-307, dMax = 1.0993296281278474e-307, cMin = 7, cMax = -1207960784, table = 0xb7fffb70, fp_lookup = {
> > > >     vals = 0x177ff8e, rules = 0x8048fa0, nalloc = 3366868, active = 3368612, inf_dmin = -0.84838487211208147,
> > > >     inf_dmax = 4.8586156784264609e-270, inf_min = -1075108428, inf_max = 3368528}}
> > > >         min = 1
> > > >         max = 63
> > > >         null_set = 1
> > > >         dmin = 0
> > > >         dmax = 0
> > > >         module = (struct GModule *) 0x53028c
> > > >         flag = {A = 0x8fdabe0, a = 0x8fdac08, c = 0x8fdac30, p = 0x8fdac58, l = 0x8fdac80, q = 0x8fdaca8, n = 0x8fdacd0,
> > > >   N = 0x8fdacf8, one = 0x530220, x = 0x8fdad48, g = 0x8fdad20, i = 0x8fdadc0, r = 0x8fdad98, C = 0x8fdad70}
> > > >         option = {cell = 0x530240, fs = 0x8fdaa70, nv = 0x8fdaac0, output = 0x8fdab10, nsteps = 0x8fdab70}
> > > > 
> > > > 
> > > > I tried to fix it with help of others to no avail:
> > > > 
> > > > http://grass.itc.it/pipermail/grass5/2004-December/016549.html
> > > > http://grass.itc.it/pipermail/grass5/2004-December/016576.html
> > > > 
> > > > http://www.intevation.de/rt/webrt?serial_num=2767&display=History
> > > > 
> > > > Can you reproduce this bug?
> > > > 
> > > > Thanks
> > > > 
> > > >  Markus
> 
> -- 
> Brad Douglas <rez at touchofmadness.com>
> 

-- 
Markus Neteler     <neteler itc it>       http://mpa.itc.it
ITC-irst -  Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18        -       38050 Povo (Trento), Italy




More information about the grass-dev mailing list