0

My speller seg faults at the space following the first word in whatever input text I use. Here is the gdb output for austinpowers.txt with the segfault just after reading the word AUSTIN:

107             else if (index > 0)
(gdb) n
110                 word[index] = '\0';
(gdb) n
113                 words++;
(gdb) print words
$13 = 0
(gdb) n
116                 getrusage(RUSAGE_SELF, &before);
(gdb) n
117                 bool misspelled = !check(word);
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x0000000000401095 in check (word=0x7fffffffdc10 "AUSTIN") at            dictionary.c:61
61              if (crawler->subnode[index] == NULL)
(gdb) 

Here is the dictionary.c code at the offending line (#61):

           if (word[i] == '\'')
    {
        index = 26;
    }

    if (crawler->subnode[index] == NULL)
    {
        return false; 
    }
    crawler->crawlersubnode[index]; 
}

return crawler->isword;

Thanks is advance for any help.

0

Not enough code to tell what's going on, but if the line if (crawler->subnode[index] == NULL) is causing the seg fault, I'd bet that at this point, crawler itself is null, so crawler->subnode doesn't exist, thus causing the seg fault. IF this isn't the problem, please edit your question and add the entire check function.

I'm also confused that you say this is happening on the space following the first word. speller shouldn't be passing any spaces on to check. Is it possible that you're not handling the end of the word correctly? are you checking that something is a word on the last letter, or are you going one character further, beyond the end of the word in the trie?

If this answers your question, please click on the check mark to accept the ansewer. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .