Maciej Sieczka wrote:
Jaros³aw Jasiewicz wrote:
> I have problem with r.reclass (and r.reclas.rules) from latest cvs
> (updated wensday morning)
> on whatever map I use it I recive segmentation fault error
I confirm for current GRASS 6.3 CVS built and running on Ubuntu
Dapper, 32 bit, GCC 4.0.3, Pentium M, kernel 2.6.15-28-686.
Any r.reclass session ends up with a segfault after the 'end' command;
eg. in spearfish:
$ r.reclass in=aspect output=tryit
> 1 thru 9.9 = 1
10.400000 rounded up to 10
> 30 thru 31 = 32
> end
Segmentation fault
Same here.
Working through a gdb session:
G63> gdb `which r.reclass`
...
(gdb) run in=aspect output=tryit
Starting program: /usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/bin/r.reclass in=aspect output=tryit
Enter rule(s), "end" when done, "help" if you need it
fp: Data range is 0.0000000000000000000000000 to 360.0000000000000000000000000
1 thru 9.9 = 1
10.400000 rounded up to 10
30 thru 31 = 32
end
Program received signal SIGSEGV, Segmentation fault.
0x40121556 in strcpy () from /lib/libc.so.6
### see where it happened
(gdb) where
#0 0x40121556 in strcpy () from /lib/libc.so.6
#1 0x0804a922 in reclass (old_name=0x804c930 "aspect", old_mapset=0x804c750 "PERMANENT",
new_name=0x804c940 "tryit", rules=0x804c790, cats=0xbffff570, title=0x0) at reclass.c:234
#2 0x08049933 in main (argc=4, argv=0xbffff6a4) at main.c:122
### in the current frame (#2) see where in the source code it was
### (main.c line 122, as shown above)
(gdb) list
122 reclass (parm.input->answer, old_mapset, parm.output->answer, rules, &cats, parm.ti tle->answer);
123
124 exit(EXIT_SUCCESS);
125 }
### main.c is just a wrapper, jump into the "#1" function as listed in
### the above "where". (#1 (...) at reclass.c:234)
(gdb) frame 1
#1 0x0804a922 in reclass (old_name=0x804c930 "aspect", old_mapset=0x804c750 "PERMANENT",
new_name=0x804c940 "tryit", rules=0x804c790, cats=0xbffff570, title=0x0) at reclass.c:234
234 strcpy (new.name, old_name);
(gdb) list
229 strcpy (new.mapset, old.mapset);
230 re_reclass (rules, cats, &old, &new, old_name, old_mapset);
231 }
232 else
233 {
234 strcpy (new.name, old_name);
235 strcpy (new.mapset, old_mapset);
236 _reclass (rules, cats, &new);
237 }
238
### print the contents of the new.name and old_name variables
(gdb) p new.name
$1 = 0xfff098 <Address 0xfff098 out of bounds>
(gdb) p old_name
$3 = 0x804c930 "aspect"
### note there is also an "old.name" variable
(gdb) p old.name
$2 = 0x0
Memory was never allocated for the "new" Reclass struct??
so strcpy() tries to copy the string into unknown memory space, and fails.
Why "10.400000 rounded up to 10". I specified range "1 thru 9.9"...
no idea.
Hamish