[GRASS-dev] d.thematic.area: need for a bit of help in
C-programming/debugging
Moritz Lennert
mlennert at club.worldonline.be
Thu Jul 24 12:46:31 EDT 2008
Hello,
I'm having a problem with the d.thematic.area module I just committed in
a modified version.
When I use the discontinuities algorithm for calculating the class
breaks, I get segmentation faults, depending on the number of classes I
ask for and on the variable I try to class.
For example, using a local copy of the censusblk_swwake in an sqlite
mapset, I run:
for var in HH_SIZE MEDIAN_AGE TOTAL_POP; do for i in 5 6 7 8 9 10; do
echo "$var, $i: "; d.thematic.area ilots colu=$var algo=dis nbcla=$i
color=254:240:217,253:204:138,252:141:89,227:74:51,179:0:0,254:240:217,253:204:138,252:141:89,227:74:51,179:0:0;
done; done
which gives me:
HH_SIZE, 5:
HH_SIZE, 6:
Segmentation fault
HH_SIZE, 7:
HH_SIZE, 8:
HH_SIZE, 9:
Segmentation fault
HH_SIZE, 10:
Segmentation fault
MEDIAN_AGE, 5:
MEDIAN_AGE, 6:
Segmentation fault
MEDIAN_AGE, 7:
MEDIAN_AGE, 8:
MEDIAN_AGE, 9:
Segmentation fault
MEDIAN_AGE, 10:
TOTAL_POP, 5:
TOTAL_POP, 6:
Segmentation fault
TOTAL_POP, 7:
TOTAL_POP, 8:
TOTAL_POP, 9:
Segmentation fault
TOTAL_POP, 10:
Segmentation fault
It seems to be linked to the class_discont function in
lib/arraystats/class.c, as this only happens with this algorithm.
However, when I do the same test with d.thematic.areas -nl flags (i.e.
don't plot the map, but only output legend info), I don't get the
segfaults, so there is some problem between this function and the
display functions.
I seem to have tracked it down to the call to Vect_new_line_struct() on
line 32 in display/d.thematic.area/area.c and from there to (I think)
Vect__new_line_struct in lib/vector/Vlib/line.c.
I imagine it is just some stupid C-novice error, probably memory
allocation somewhere, so I would really appreciate if someone with the
relevant knowledge could just glance over the code to see if there is
something obvious...
Moritz
More information about the grass-dev
mailing list