[GRASS-dev] Re: [GRASS GIS] #718: r.li forgets mask/illegal filename
GRASS GIS
trac at osgeo.org
Tue Aug 18 05:50:18 EDT 2009
#718: r.li forgets mask/illegal filename
------------------------+---------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev at lists.osgeo.org
Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: Raster | Version: 6.4.0 RCs
Resolution: | Keywords: r.li, smp
Platform: All | Cpu: All
------------------------+---------------------------------------------------
Comment (by hamish):
> Replying to [comment:16 hamish]:
> > i.e. strtok() is not thread safe and it is being used in a thread.
Replying to [comment:18 glynn]:
> Huh? AFAICT, r.li doesn't use threads, it uses multiple processes.
um, sorry about that. my bad... ok, so it's not a thread-safe issue and
strtok() has been unjustly blamed; and the change to strtok_r() doesn't
help. I still can't find any joy with gdb so resorting to sticking
printf()s everywhere. With that I can see that it is falling over in
r.li.daemon/list.c's insertNode() on the first malloc() on the second time
that function is called.
source:grass/trunk/raster/r.li/r.li.daemon/list.c at 38777#L32
{{{
void insertNode(list l, msg mess)
{
node new;
new = G_malloc(sizeof(node));
...
}}}
size(node) is 4 on the pass where it dies.
unfortunately I'm guessing that just means that the memory is already
corrupt by the time it gets there. :(
which puts us back a step in the daemon.c SAMPLEAREA while loop:
source:grass/trunk/raster/r.li/r.li.daemon/daemon.c at 38777#L367
If I pepper a bunch of test G_malloc()s here and there in that while loop
it succeeds right up to the point -on the first pass- where insertNode()
is called within the else{}. A G_malloc() just after that causes glibc to
report the error.
Valgrind finds a whole pile of errors:
{{{
G65:nc_spm_08> CMD="r.li.shannon map=landclass96 conf=landclass96_conf2
output=landclass96_shannon"
G65:nc_spm_08> valgrind --tool=memcheck $CMD
==4276== Memcheck, a memory error detector.
==4276== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==4276== Using LibVEX rev 1658, a library for dynamic binary translation.
==4276== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==4276== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation
framework.
==4276== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==4276== For more details, rerun with: -v
==4276==
==4276== Invalid write of size 4
==4276== at 0x40B445E: insertNode (list.c:32)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x4217840 is 4 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 4
==4276== at 0x40B446A: insertNode (list.c:35)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x4217840 is 4 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid write of size 4
==4276== at 0x40B4498: insertNode (list.c:36)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x421783C is 0 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Conditional jump or move depends on uninitialised value(s)
==4276== at 0x40B44A2: insertNode (list.c:38)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid write of size 4
==4276== at 0x40B44C3: insertNode (list.c:42)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x421783C is 0 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 1
==4276== at 0x4149FE7: strtok (in /lib/tls/i686/cmov/libc-2.3.6.so)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x4216B40 is 0 bytes after a block of size 288 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B2734: parseSetup (daemon.c:319)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 1
==4276== at 0x414A00F: strtok (in /lib/tls/i686/cmov/libc-2.3.6.so)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x4216B40 is 0 bytes after a block of size 288 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B2734: parseSetup (daemon.c:319)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Conditional jump or move depends on uninitialised value(s)
==4276== at 0x40B3F6E: next_Area (daemon.c:640)
==4276== by 0x40B1FD2: calculateIndex (daemon.c:147)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 4
==4276== at 0x40B3F81: next_Area (daemon.c:645)
==4276== by 0x40B1FD2: calculateIndex (daemon.c:147)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x4217840 is 4 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 4
==4276== at 0x40B451F: removeNode (list.c:63)
==4276== by 0x40B3FCB: next_Area (daemon.c:647)
==4276== by 0x40B1FD2: calculateIndex (daemon.c:147)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x421783C is 0 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Invalid read of size 4
==4276== at 0x40B4560: removeNode (list.c:73)
==4276== by 0x40B3FCB: next_Area (daemon.c:647)
==4276== by 0x40B1FD2: calculateIndex (daemon.c:147)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0x421783C is 0 bytes after a block of size 4 alloc'd
==4276== at 0x401D38B: malloc (vg_replace_malloc.c:149)
==4276== by 0x402EB8D: G__malloc (alloc.c:41)
==4276== by 0x40B4437: insertNode (list.c:31)
==4276== by 0x40B2DCD: parseSetup (daemon.c:399)
==4276== by 0x40B1DF3: calculateIndex (daemon.c:106)
==4276== by 0x8048D12: main (shannon.c:58)
==4276==
==4276== Syscall param write(buf) points to uninitialised byte(s)
==4276== at 0x4000792: (within /lib/ld-2.3.6.so)
==4276== by 0x40B1FA0: calculateIndex (daemon.c:148)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0xBED61FFC is on thread 1's stack
==4276==
==4276== Conditional jump or move depends on uninitialised value(s)
==4276== at 0x40B3F6E: next_Area (daemon.c:640)
==4276== by 0x40B2198: calculateIndex (daemon.c:154)
==4276== by 0x8048D12: main (shannon.c:58)
==4277== Conditional jump or move depends on uninitialised value(s)
==4277== at 0x40B5381: RLI_get_cell_raster_row (worker.c:279)
==4277== by 0x8048F51: calculate (shannon.c:167)
==4277== by 0x8048DBF: shannon (shannon.c:84)
==4277== by 0x40B500B: worker (worker.c:192)
==4277== by 0x40B1D52: calculateIndex (daemon.c:91)
==4277== by 0x8048D12: main (shannon.c:58)
====4279== Conditional jump or move depends on uninitialised value(s)
==4279== at 0x40B5381: RLI_get_cell_raster_row (worker.c:279)
==4279== by 0x8048F51: calculate (shannon.c:167)
==4279== by 0x8048DBF: shannon (shannon.c:84)
==4279== by 0x40B500B: worker (worker.c:192)
==4279== by 0x40B1D52: calculateIndex (daemon.c:91)
==4279== by 0x8048D12: main (shannon.c:58)
4278== Conditional jump or move depends on uninitialised value(s)
==4278== at 0x40B5381: RLI_get_cell_raster_row (worker.c:279)
==4278== by 0x8048F51: calculate (shannon.c:167)
==4278== by 0x8048DBF: shannon (shannon.c:84)
==4278== by 0x40B500B: worker (worker.c:192)
==4278== by 0x40B1D52: calculateIndex (daemon.c:91)
==4278== by 0x8048D12: main (shannon.c:58)
====4278==
==4278== Syscall param write(buf) points to uninitialised byte(s)
==4278== at 0x4000792: (within /lib/ld-2.3.6.so)
==4278== by 0x40B506F: worker (worker.c:206)
==4278== by 0x40B1D52: calculateIndex (daemon.c:91)
==4278== by 0x8048D12: main (shannon.c:58)
==4278== Address 0xBED61AF8 is on thread 1's stack
4277==
==4277== Syscall param write(buf) points to uninitialised byte(s)
==4277== at 0x4000792: (within /lib/ld-2.3.6.so)
==4277== by 0x40B506F: worker (worker.c:206)
==4277== by 0x40B1D52: calculateIndex (daemon.c:91)
==4277== by 0x8048D12: main (shannon.c:58)
==4277== Address 0xBED61AF8 is on thread 1's stack
==4276==
==4276== Syscall param write(buf) points to uninitialised byte(s)
==4276== at 0x4000792: (within /lib/ld-2.3.6.so)
==4276== by 0x40B2354: calculateIndex (daemon.c:230)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0xBED61FFC is on thread 1's stack
==4279==
==4279== Syscall param write(buf) points to uninitialised byte(s)
==4279== at 0x4000792: (within /lib/ld-2.3.6.so)
==4279== by 0x40B506F: worker (worker.c:206)
==4279== by 0x40B1D52: calculateIndex (daemon.c:91)
==4279== by 0x8048D12: main (shannon.c:58)
==4279== Address 0xBED61AF8 is on thread 1's stack
==4278==
==4278== ERROR SUMMARY: 21 errors from 2 contexts (suppressed: 23 from 1)
==4278== malloc/free: in use at exit: 83,775 bytes in 90 blocks.
==4278== malloc/free: 280 allocs, 190 frees, 101,718 bytes allocated.
==4278== For counts of detected errors, rerun with: -v
==4278== searching for pointers to 90 not-freed blocks.
==4278== checked 135,736 bytes.
==4278==
==4278== LEAK SUMMARY:
==4278== definitely lost: 60,587 bytes in 45 blocks.
==4278== possibly lost: 0 bytes in 0 blocks.
==4278== still reachable: 23,188 bytes in 45 blocks.
==4278== suppressed: 0 bytes in 0 blocks.
==4278== Use --leak-check=full to see details of leaked memory.
==4277==
==4277== ERROR SUMMARY: 21 errors from 2 contexts (suppressed: 23 from 1)
==4277== malloc/free: in use at exit: 83,165 bytes in 87 blocks.
==4277== malloc/free: 275 allocs, 188 frees, 101,034 bytes allocated.
==4277== For counts of detected errors, rerun with: -v
==4277== searching for pointers to 87 not-freed blocks.
==4277== checked 135,124 bytes.
==4277==
==4277== LEAK SUMMARY:
==4277== definitely lost: 60,543 bytes in 43 blocks.
==4277== possibly lost: 0 bytes in 0 blocks.
==4277== still reachable: 22,622 bytes in 44 blocks.
==4277== suppressed: 0 bytes in 0 blocks.
==4277== Use --leak-check=full to see details of leaked memory.
==4279==
==4279== ERROR SUMMARY: 42 errors from 2 contexts (suppressed: 23 from 1)
==4279== malloc/free: in use at exit: 128,639 bytes in 115 blocks.
==4279== malloc/free: 337 allocs, 222 frees, 148,422 bytes allocated.
==4279== For counts of detected errors, rerun with: -v
==4279== searching for pointers to 115 not-freed blocks.
==4279== checked 138,420 bytes.
==4279==
==4279== LEAK SUMMARY:
==4279== definitely lost: 102,777 bytes in 68 blocks.
==4279== possibly lost: 2,108 bytes in 1 blocks.
==4279== still reachable: 23,754 bytes in 46 blocks.
==4279== suppressed: 0 bytes in 0 blocks.
==4279== Use --leak-check=full to see details of leaked memory.
==4276==
==4276== Syscall param write(buf) points to uninitialised byte(s)
==4276== at 0x4000792: (within /lib/ld-2.3.6.so)
==4276== by 0x40B24A4: calculateIndex (daemon.c:255)
==4276== by 0x8048D12: main (shannon.c:58)
==4276== Address 0xBED61FFC is on thread 1's stack
==4280==
==4280== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4280== malloc/free: in use at exit: 40,433 bytes in 60 blocks.
==4280== malloc/free: 203 allocs, 143 frees, 55,540 bytes allocated.
==4280== For counts of detected errors, rerun with: -v
==4280== searching for pointers to 60 not-freed blocks.
==4280== checked 136,096 bytes.
==4280==
==4280== LEAK SUMMARY:
==4280== definitely lost: 16,113 bytes in 13 blocks.
==4280== possibly lost: 0 bytes in 0 blocks.
==4280== still reachable: 24,320 bytes in 47 blocks.
==4280== suppressed: 0 bytes in 0 blocks.
==4280== Use --leak-check=full to see details of leaked memory.
==4282==
==4282== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4282== malloc/free: in use at exit: 40,999 bytes in 61 blocks.
==4282== malloc/free: 206 allocs, 145 frees, 56,164 bytes allocated.
==4282== For counts of detected errors, rerun with: -v
==4282== searching for pointers to 61 not-freed blocks.
==4282== checked 136,672 bytes.
==4282==
==4282== LEAK SUMMARY:
==4282== definitely lost: 16,113 bytes in 13 blocks.
==4282== possibly lost: 0 bytes in 0 blocks.
==4282== still reachable: 24,886 bytes in 48 blocks.
==4282== suppressed: 0 bytes in 0 blocks.
==4282== Use --leak-check=full to see details of leaked memory.
==4284==
==4284== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4284== malloc/free: in use at exit: 41,565 bytes in 62 blocks.
==4284== malloc/free: 209 allocs, 147 frees, 56,788 bytes allocated.
==4284== For counts of detected errors, rerun with: -v
==4284== searching for pointers to 62 not-freed blocks.
==4284== checked 137,248 bytes.
==4284==
==4284== LEAK SUMMARY:
==4284== definitely lost: 16,113 bytes in 13 blocks.
==4284== possibly lost: 0 bytes in 0 blocks.
==4284== still reachable: 25,452 bytes in 49 blocks.
==4284== suppressed: 0 bytes in 0 blocks.
==4284== Use --leak-check=full to see details of leaked memory.
==4285==
==4285== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4285== malloc/free: in use at exit: 42,131 bytes in 63 blocks.
==4285== malloc/free: 212 allocs, 149 frees, 57,412 bytes allocated.
==4285== For counts of detected errors, rerun with: -v
==4285== searching for pointers to 63 not-freed blocks.
==4285== checked 137,824 bytes.
==4285==
==4285== LEAK SUMMARY:
==4285== definitely lost: 16,113 bytes in 13 blocks.
==4285== possibly lost: 0 bytes in 0 blocks.
==4285== still reachable: 26,018 bytes in 50 blocks.
==4285== suppressed: 0 bytes in 0 blocks.
==4285== Use --leak-check=full to see details of leaked memory.
==4286==
==4286== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4286== malloc/free: in use at exit: 42,697 bytes in 64 blocks.
==4286== malloc/free: 215 allocs, 151 frees, 58,036 bytes allocated.
==4286== For counts of detected errors, rerun with: -v
==4286== searching for pointers to 64 not-freed blocks.
==4286== checked 138,400 bytes.
==4286==
==4286== LEAK SUMMARY:
==4286== definitely lost: 16,113 bytes in 13 blocks.
==4286== possibly lost: 0 bytes in 0 blocks.
==4286== still reachable: 26,584 bytes in 51 blocks.
==4286== suppressed: 0 bytes in 0 blocks.
==4286== Use --leak-check=full to see details of leaked memory.
==4287==
==4287== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4287== malloc/free: in use at exit: 43,263 bytes in 65 blocks.
==4287== malloc/free: 218 allocs, 153 frees, 58,660 bytes allocated.
==4287== For counts of detected errors, rerun with: -v
==4287== searching for pointers to 65 not-freed blocks.
==4287== checked 138,976 bytes.
==4287==
==4287== LEAK SUMMARY:
==4287== definitely lost: 16,113 bytes in 13 blocks.
==4287== possibly lost: 0 bytes in 0 blocks.
==4287== still reachable: 27,150 bytes in 52 blocks.
==4287== suppressed: 0 bytes in 0 blocks.
==4287== Use --leak-check=full to see details of leaked memory.
==4288==
==4288== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
==4288== malloc/free: in use at exit: 43,830 bytes in 66 blocks.
==4288== malloc/free: 221 allocs, 155 frees, 59,285 bytes allocated.
==4288== For counts of detected errors, rerun with: -v
==4288== searching for pointers to 66 not-freed blocks.
==4288== checked 139,552 bytes.
==4288==
==4288== LEAK SUMMARY:
==4288== definitely lost: 16,113 bytes in 13 blocks.
==4288== possibly lost: 0 bytes in 0 blocks.
==4288== still reachable: 27,717 bytes in 53 blocks.
==4288== suppressed: 0 bytes in 0 blocks.
==4288== Use --leak-check=full to see details of leaked memory.
==4276==
==4276== ERROR SUMMARY: 40 errors from 15 contexts (suppressed: 23 from 1)
==4276== malloc/free: in use at exit: 2,489 bytes in 53 blocks.
==4276== malloc/free: 117 allocs, 64 frees, 5,458 bytes allocated.
==4276== For counts of detected errors, rerun with: -v
==4276== searching for pointers to 53 not-freed blocks.
==4276== checked 122,368 bytes.
==4276==
==4276== LEAK SUMMARY:
==4276== definitely lost: 1,816 bytes in 18 blocks.
==4276== possibly lost: 0 bytes in 0 blocks.
==4276== still reachable: 673 bytes in 35 blocks.
==4276== suppressed: 0 bytes in 0 blocks.
==4276== Use --leak-check=full to see details of leaked memory.
}}}
(11 error summaries from 10 workers and 1 master process)
Hamish
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/718#comment:19>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list