[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help for SIGSEGV in test suite needed when built with gcc 8.2 what works nicely with gcc 6.3



On 2019-01-09, Andrey Rahmatullin <wrar@debian.org> wrote:
> As usual: reading the code, debugging, printfs. Address sanitizer and/or
> valgrind may or may not help too.

I just tried throwing some tools at it.

Apparantly you need a three step thing to get to it.

address-sanitizer. First issue. The command to create the test data to
get the error.

$ ./ffindex_build -s ./test.data ./test.ffindex test/data test/data2

=================================================================
==824==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 304 byte(s) in 1 object(s) allocated from:
    #0 0x7f3393888ed0 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe8ed0)
    #1 0x7f33937994f1 in ffindex_index_parse /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:325
    #2 0x56072c890783 in main /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex_build.c:243
    #3 0x7f33935f9b16 in __libc_start_main ../csu/libc-start.c:310

SUMMARY: AddressSanitizer: 304 byte(s) leaked in 1 allocation(s).


Oh well. rebuild without address sanitizer and run the first two steps.
Then rebuild with address sanitizer for the last step.

$ ./ffindex_modify -u ./test.ffindex b
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1453==ERROR: AddressSanitizer: SEGV on unknown address 0x000ca3ff8001 (pc 0x7f459600a9f7 bp 0x7ffd6674b8d0 sp 0x7ffd6674b8a0 T0)
==1453==The signal is caused by a READ memory access.
    #0 0x7f459600a9f6 in action /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:554
    #1 0x7f45960076ed in trecursemisc /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/twalkmisc.h:26
    #2 0x7f459600775d in trecursemisc /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/twalkmisc.h:31
    #3 0x7f4596007827 in twalkmisc /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/twalkmisc.h:44
    #4 0x7f459600aac3 in ffindex_tree_write /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:563
    #5 0x7f4596009f60 in ffindex_write /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:443
    #6 0x55c8564c3fa8 in main /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex_modify.c:182
    #7 0x7f4595e69b16 in __libc_start_main ../csu/libc-start.c:310
    #8 0x55c8564c3259 in _start (/home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/build/src/ffindex_modify+0x2259)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/sune/src/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:554 in action
==1453==ABORTING

I'm not sure that gives more new info.

Lets try valgrind.

$ valgrind ./ffindex_modify -u ./test.ffindex b
==32176== Memcheck, a memory error detector
==32176== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==32176== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==32176== Command: ./ffindex_modify -u ./test.ffindex b
==32176== 
==32176== Invalid read of size 8
==32176==    at 0x4846525: trecursemisc (twalkmisc.h:25)
==32176==    by 0x484658E: trecursemisc (twalkmisc.h:31)
==32176==    by 0x4846633: twalkmisc (twalkmisc.h:44)
==32176==    by 0x4847CE0: ffindex_tree_write (ffindex.c:563)
==32176==    by 0x48477C2: ffindex_write (ffindex.c:443)
==32176==    by 0x10985E: main (ffindex_modify.c:182)
==32176==  Address 0x4a536e1 is 17 bytes inside a block of size 24 alloc'd
==32176==    at 0x483577F: malloc (vg_replace_malloc.c:299)
==32176==    by 0x4986160: tsearch (tsearch.c:338)
==32176==    by 0x4847C02: ffindex_index_as_tree (ffindex.c:533)
==32176==    by 0x1094D7: main (ffindex_modify.c:122)
==32176== 
==32176== Invalid read of size 8
==32176==    at 0x4847C6D: action (ffindex.c:554)
==32176==    by 0x4846543: trecursemisc (twalkmisc.h:26)
==32176==    by 0x484658E: trecursemisc (twalkmisc.h:31)
==32176==    by 0x4846633: twalkmisc (twalkmisc.h:44)
==32176==    by 0x4847CE0: ffindex_tree_write (ffindex.c:563)
==32176==    by 0x48477C2: ffindex_write (ffindex.c:443)
==32176==    by 0x10985E: main (ffindex_modify.c:182)
==32176==  Address 0x4a53d is not stack'd, malloc'd or (recently) free'd
==32176== 
==32176== 
==32176== Process terminating with default action of signal 11 (SIGSEGV)
==32176==  Access not within mapped region at address 0x4A53D
==32176==    at 0x4847C6D: action (ffindex.c:554)
==32176==    by 0x4846543: trecursemisc (twalkmisc.h:26)
==32176==    by 0x484658E: trecursemisc (twalkmisc.h:31)
==32176==    by 0x4846633: twalkmisc (twalkmisc.h:44)
==32176==    by 0x4847CE0: ffindex_tree_write (ffindex.c:563)
==32176==    by 0x48477C2: ffindex_write (ffindex.c:443)
==32176==    by 0x10985E: main (ffindex_modify.c:182)
==32176==  If you believe this happened as a result of a stack
==32176==  overflow in your program's main thread (unlikely but
==32176==  possible), you can try to increase the size of the
==32176==  main thread stack using the --main-stacksize= flag.
==32176==  The main thread stack size used in this run was 8388608.
==32176== 
==32176== HEAP SUMMARY:
==32176==     in use at exit: 928 bytes in 5 blocks
==32176==   total heap usage: 9 allocs, 4 frees, 6,152 bytes allocated
==32176== 
==32176== LEAK SUMMARY:
==32176==    definitely lost: 0 bytes in 0 blocks
==32176==    indirectly lost: 0 bytes in 0 blocks
==32176==      possibly lost: 24 bytes in 1 blocks
==32176==    still reachable: 904 bytes in 4 blocks
==32176==         suppressed: 0 bytes in 0 blocks
==32176== Rerun with --leak-check=full to see details of leaked memory
==32176== 
==32176== For counts of detected and suppressed errors, rerun with: -v
==32176== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Segmentation fault


I looked briefly at the code, but I didn't feel like actually trying to
understand what's going on.

/Sune


Reply to: