Opened 15 years ago

Closed 14 years ago

#455 closed defect (fixed)

d.what.rast segfault

Reported by: hamish Owned by: grass-dev@…
Priority: major Milestone: 6.4.0
Component: Default Version: unspecified
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

Hi,

d.what.rast segfaults for me in latest develbranch6, but not in 6.3.0 or 6.4.0RC2.

spearfish:

g.region rast=elevation.dem
r.param.scale in=elevation.dem out=elev.asp_param param=aspect
d.mon x0
d.rast elev.asp_param
d.what.rast

Buttons
 Left:  what's here
 Right: quit

603131.5625(E) 4924637.1875(N)
elev.asp_param@user1 in user1, quant   (-59)
Segmentation fault

"map@mapset in mapset"??

(gdb) bt
#0  0xb7f0e72a in G_get_raster_cat (rast=0x80598f0, pcats=0x8051b68, data_type=2)
    at cats.c:673
#1  0xb7f0e675 in G_get_d_raster_cat (rast=0x80598f0, pcats=0x8051b68) at cats.c:636
#2  0x0804aca3 in what (once=0, terse=0, colrow=0, fs=0x804af63 ":", width=20, mwidth=5)
    at what.c:82
#3  0x08049bfa in main (argc=1, argv=0xbff90cf4) at main.c:170

(gdb) bt full
#0  0xb7f0e72a in G_get_raster_cat (rast=0x80598f0, pcats=0x8051b68, data_type=2)
    at cats.c:673
        f = 0x8051d46 ""
        l = 0xbff909c8 "è\nù¿£¬\004\bð\230\005\bh\033\005\bl"
        v = 0xb7f71090 "ZY\207\004$Â\b"
        i = -2147483648
        val = -90.842525032748952
        a = {-2.86272261e-05, -2.9214556e-05}
        fmt = "\000\000\001\000\000\000\001\000\000\000\000\000\000\000,8ð·Õ\002\000\000\000                         àï·¬8\005"
        value_str = "\000põ·ô¿÷·\000põ·\001\000\000\000\220\tù¿ù\022÷·¬qõ·\000"
        label = '\0' <repeats 1023 times>
#1  0xb7f0e675 in G_get_d_raster_cat (rast=0x80598f0, pcats=0x8051b68) at cats.c:636
No locals.
#2 [...]

?? Hamish

Change History (2)

comment:1 by hamish, 15 years ago

Hi,

this bug is probably related to incomplete #392 (backport G_is_c_null_value() to devbr6).

It fails here:

#0  0xb7f0e72a in G_get_raster_cat (rast=0x80598f0, pcats=0x8051b68, data_type=2)
    at cats.c:673

which is:

    if (!G_is_c_null_value(&i) && i < pcats->ncats) {
	if (pcats->labels[i] != NULL)
	    return pcats->labels[i];
	return label;
    }

because i = -2147483648 and the pcats->labels[i] lookup fails.

So either G_quant_get_cell_value() is setting i wrong, or G_is_c_null_value() is testing it wrong.

stepping through in the debugger shows that G_quant_get_cell_value() does [lib/gis/quant.c:line 798]

    if (NO_EXPLICIT_RULE)
        return NO_DATA;
    if (NO_EXPLICIT_RULE)
        return NO_DATA;

(huh? why twice?)

earlier, #define NO_DATA (G_set_c_null_value (&tmp, 1), (CELL) tmp)

and

GR6.5> r.info -t elev.sl.parm.scale
datatype=DCELL

In this case I was clicking on non-NULL data:

D0/0: G_get_raster_cat(): val 131.987214 found i -2147483648

?, Hamish

comment:2 by hamish, 14 years ago

Resolution: fixed
Status: newclosed

appears to be fixed.

Note: See TracTickets for help on using tickets.