[GRASS-user] bug in r.pi.nlm add-on module

Martin Wegmann wegmann2011 at googlemail.com
Wed Feb 1 11:06:01 EST 2012


Hello,

I encountered a bug in an add-on module, r.pi.nlm (on several Ubuntu 11.10. 
systems) and Markus could replicate the bug and also found the part where the 
error occurs. 

I tested it with regions 10x10 pixel up to 1000x1000 px - the error messages 
are the same but time until they occured increased.

If somebody would have an idea how to fix it, I would be very grateful.

regards, Martin

P.S.: r.pi.nlm is generating a random fractal landscape either based on an 
input map or by defining the percentage cover (0-100%) and 
sharpness/agglomeration (0-1) factor.

r.pi.nlm input=landuse96_28m keyval=4 output=nlm1

======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f4b826e87f7]
/lib/x86_64-linux-gnu/libc.so.6(+0xf7710)[0x7f4b826e7710]
r.pi.nlm(CutValues+0x76)[0x402286]
r.pi.nlm(main+0x58e)[0x401aee]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f4b8261130d]
r.pi.nlm[0x401e15]
======= Memory map: ========
00400000-00404000 r-xp 00000000 08:01 656696                             
/usr/local/grass-6.4.2svn/bin/r.pi.nlm
00603000-00604000 r--p 00003000 08:01 656696                             
/usr/local/grass-6.4.2svn/bin/r.pi.nlm
00604000-00605000 rw-p 00004000 08:01 656696                             
/usr/local/grass-6.4.2svn/bin/r.pi.nlm
01669000-0168a000 rw-p 00000000 00:00 0                                  
[heap]
[...]
(can send the whole error message if asked for)


Markus error log with gdb:


(gdb) r.pi.nlm input=landclass96 keyval=5 output=test --o
Starting program: /home/neteler/grass64/dist.x86_64-unknown-linux-
gnu/bin/r.pi.nlm input=landclass96 keyval=5 output=test --o

Program received signal SIGSEGV, Segmentation fault.
0x0000000000401ac3 in CutValues (map=0x7ffff7fd8010, 
mapcover=0.49554953560371517, size=16641)
    at func.c:128
128             values[index]++;
Missing debug package(s), you should install: glibc-
debug-2.11.1-8.3mnb2.x86_64 zlib-debug-1.2.3-15mdv2010.1.x86_64
(gdb) bt full
#0  0x0000000000401ac3 in CutValues (map=0x7ffff7fd8010, 
mapcover=0.49554953560371517, size=16641)
    at func.c:128
        values = {0 <repeats 9999 times>}
        min = 1000000
        max = 1000000
        span = 0
        c = inf
        pixels = 8246
        i = 0
        j = -11408
        index = -2147483648
                ^^^^^^^^^^^^ --!

in func.c:
double CutValues(double *map, double mapcover, int size)
{
    int values[RESOLUTION - 1];
    double min, max, span, c;
    int pixels;
    int i, j, index;
    int bottom, top;
    int topdif, bottomdif;

    // get parameters
    MinMax(map, &min, &max, size);
    span = max - min;
    c = min / span;
    pixels = Round(size * mapcover);

    // classify heights
    memset(values, 0, RESOLUTION * sizeof(int));
    for (i = 0; i < size; i++) {
        index = floor(RESOLUTION * (map[i] - min) / span);
        ^^^^^^--- negative

    Then the subsequent values[index] crashes.


More information about the grass-user mailing list