1

I've got my speller working fine and without errors, but it does not currently pass check50 as Valgrind finds few issues. My problem is that I do not understand at all what they are, what is causing them and thus how to fix it. I have tried googling a bit, but everything I find is still too complex for me to understand.

Here's the snippet from valgrind that is giving me problems currently:

==9233== Conditional jump or move depends on uninitialised value(s)
==9233==    at 0x59ACE8F: tolower (ctype.c:46)
==9233==    by 0x422474: check (dictionary.c:23)
==9233==    by 0x4213F3: main (speller.c:112)
==9233==  Uninitialised value was created by a stack allocation
==9233==    at 0x4208F4: main (speller.c:21)
==9233== 
==9233== Use of uninitialised value of size 8
==9233==    at 0x59ACEA3: tolower (ctype.c:46)
==9233==    by 0x422474: check (dictionary.c:23)
==9233==    by 0x4213F3: main (speller.c:112)
==9233==  Uninitialised value was created by a stack allocation
==9233==    at 0x4208F4: main (speller.c:21)
==9233== 
1

valgrind has figured that the variable you pass to tolower (declared on line 21 in speller.c, which is strange, as that's code that should be correct) might not have been initialised. This might happen for example if you assign a value only in a if path, but you don't in the corresponding else path. Using a non-initialised value is a sure way to create bugs that appear on one machine but not on another, or appear only under heavy load, or heisenbugs, bugs that will change as soon as you try to debug them.

The "jump or move" most likely relates to a loop or if, where the branch taken depends on a condition that uses the uninitialised variable.

1
  • That helped me figure it out. The problem was in how I iterated the for loop for storing the passed in word in check function. I used the defined LENGTH+1 for the size of the loop, but that created bunch of uninitialized values for all words shorter than 45 characters. Solution was to get the length of the word being passed in and use that instead.
    – MVierma
    Feb 12 '18 at 17:42

You must log in to answer this question.

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