##################################### C-code: - r.pi.nlm, r.pi.nlm.stats are broken - fix all the unused variables - fix remaining compiler warnings - there are LOTs of cloned files, put them into a r.pi library (example: ~/grass64/vector/lidar/lidarlib/) File counts: - search.c 5 - func.c 16 - frag.c 7 To compare: for i in search.cfunc.c frag.c ; do echo "####### $i:" ls -l */$i done - some modules allow to choose between 4 or 8 neighbors, but hardcode neighbors to 4 (e.g. r.pi.energy) - fragment IDs: eliminate usage of COORDS *cells and Coords **fragments to save memory ###### can this bug be replicated? ##### r.pi.nlm input=landclass96 keyval=5 output=test --o or r.pi.nlm output=test landcover=50 --o gives: *** buffer overflow detected ***: r.pi.nlm terminated --> Please rerun with gdb gdb r.pi.nlm r input=landclass96 keyval=5 output=test --o bt full This will generate a full backtrace if GRASS was compiled with "-g", i.e. debugging. See http://grass.osgeo.org/wiki/GRASS_Debugging#Using_GDB Got it, too: (gdb) r 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 } 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. ---can you add a loop which looks to see if min[i] (bigbuf) constains silly values? i.e. did the nan cleanout by MinMax() in main.c really work? why are those nans in there in the first place? maybe if we get rid of them the problem goes away.. ##################################### HTML Descriptions TODO: - Add North Carolina example to each module, a section has been included everywhere - ./description.html (overview): polish and update to current module names - module/description.html files: still TOO GENERAL