soedinglab / ffindex_soedinglab

Other
16 stars 2 forks source link

ffindex_modify segfaults during tests #7

Open tillea opened 5 years ago

tillea commented 5 years ago

Hi, I just learned in Issue 4 that I might have grabbed the wrong codebase for Debian when I pointed it to this Git repository. However, you might be interested to know that ffindex_modify segfaults in our test suite which you can see in the Debian bug report. Hope this helps, Andreas.

tillea commented 5 years ago

Hi, I have tracked down the issue in a gdb session:

ffindex_build -s ./test.data ./test.ffindex test/data test/data2
ffindex_get  ./test.data ./test.ffindex a b foo | tee ./test.out
a
bb
fooo
fooo
gdb --args ffindex_modify -u ./test.ffindex b
GNU gdb (Debian 8.2-1) 8.2
...
(gdb) break src/ffindex.c:553
Breakpoint 1 (src/ffindex.c:553) pending.
(gdb) run
Starting program: ffindex_modify -u ./test.ffindex b

Breakpoint 1, action (node=0x555555559801, which=postorder, depth=1, misc=0x555555559260) at /build/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:553
553                 entry = *(ffindex_entry_t **) node;
(gdb) print entry
$1 = (ffindex_entry_t *) 0x7
(gdb) print entry->offset
Cannot access memory at address 0x7
(gdb) next
554                 if(fprintf(index_file, "%s\t%zd\t%zd\n", entry->name, entry->offset, entry->length) < 0)
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f7bc6d in action (node=0x555555559801, which=postorder, depth=1, misc=0x555555559260) at /build/ffindex-0.9.9.7.soedinglab+git20171201.74550c8/src/ffindex.c:554
554                 if(fprintf(index_file, "%s\t%zd\t%zd\n", entry->name, entry->offset, entry->length) < 0)

So the SIGSEGV occures in the attempt to access any member of the struct entry (I have some more detailed debugging code which proves this statement). Another thing to consider is that this SIGSEGV occures only for gcc 8.2. When using Debian stable featuring gcc 6.3 the problem does not occure and the test runs fine. Hope this helps.

tillea commented 5 years ago

Hi again, there is now more input in the Debian bug log with analysis using AdressSanitizer and valgrind. Hope this helps.

ahcm commented 5 years ago

I added the compatibility changes to ffindex and made a new release: https://github.com/ahcm/ffindex/releases/tag/0.9.9.8

I also forked the hh-suite code and only changed the ffindex submodule that is used: https://github.com/ahcm/hh-suite