Open stephenmathieson opened 10 years ago
valgrind(1) provides a bit more detail:
$ DEBUG=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z valgrind ./test
==3890== Memcheck, a memory error detector
==3890== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3890== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3890== Command: ./test
==3890==
==3890== Invalid write of size 8
==3890== at 0x400984: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890== Address 0x51f2040 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x40099B: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890== Address 0x51f2048 is 7 bytes after a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid read of size 8
==3890== at 0x400890: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890== Address 0x51f2040 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400BEA: _debug_active (in /home/stephen/debug/test)
==3890== by 0x4006CD: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x400984: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890== Address 0x51f2570 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x40099B: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890== Address 0x51f2578 is 7 bytes after a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid read of size 8
==3890== at 0x400890: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890== Address 0x51f2570 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400B0A: _debug_inactive (in /home/stephen/debug/test)
==3890== by 0x4006DC: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x400984: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890== Address 0x51f2aa0 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x40099B: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890== Address 0x51f2aa8 is 7 bytes after a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid read of size 8
==3890== at 0x400890: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890== Address 0x51f2aa0 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400E8A: _debug_foobar (in /home/stephen/debug/test)
==3890== by 0x400714: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x400984: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890== Address 0x51f2fd0 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x40099B: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890== Address 0x51f2fd8 is 7 bytes after a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid read of size 8
==3890== at 0x400890: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890== Address 0x51f2fd0 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400DAA: _debug_foo_bar (in /home/stephen/debug/test)
==3890== by 0x400723: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x400984: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890== Address 0x51f3500 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid write of size 8
==3890== at 0x40099B: strsplit (in /home/stephen/debug/test)
==3890== by 0x400867: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890== Address 0x51f3508 is 7 bytes after a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890==
==3890== Invalid read of size 8
==3890== at 0x400890: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890== Address 0x51f3500 is 0 bytes inside a block of size 1 alloc'd
==3890== at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3890== by 0x400852: debug_enabled (in /home/stephen/debug/test)
==3890== by 0x400CCA: _debug_foobaz (in /home/stephen/debug/test)
==3890== by 0x400732: main (in /home/stephen/debug/test)
==3890==
==3890==
==3890== HEAP SUMMARY:
==3890== in use at exit: 145 bytes in 75 blocks
==3890== total heap usage: 80 allocs, 5 frees, 405 bytes allocated
==3890==
==3890== LEAK SUMMARY:
==3890== definitely lost: 145 bytes in 75 blocks
==3890== indirectly lost: 0 bytes in 0 blocks
==3890== possibly lost: 0 bytes in 0 blocks
==3890== still reachable: 0 bytes in 0 blocks
==3890== suppressed: 0 bytes in 0 blocks
==3890== Rerun with --leak-check=full to see details of leaked memory
==3890==
==3890== For counts of detected and suppressed errors, rerun with: -v
==3890== ERROR SUMMARY: 120 errors from 15 contexts (suppressed: 2 from 2)
@jwerle we could use something like occurrences.c, but that will make a noticeable performance impact :/
We're only requesting an array with one element, which causes nasal demons: