1

I have been looking for a similar post to mine without success. I am working with a code that so far seems to be deterministic and is as of now working properly. However when running Valgrind memcheck on it I get thousands of warnings all referencing to "conditional jump or move depends on unninitialised value". When tracing the error, valgrind trace it back to brk and sbrk functions. I do not understand why this is happening?, and more importantly how to fix it?. Below a portion of my code.

    navSolutions->channel.satPositions = (fl64 **) calloc(3 , sizeof(fl64*));
    ERRORCHECK(navSolutions->channel.satPositions == NULL)

    navSolutions->channel.satPositionsOld = (fl64 **) calloc(3 , sizeof(fl64*));
    ERRORCHECK(navSolutions->channel.satPositionsOld == NULL)

It is also relevant that a lot of these calls happen when calling free() for each of the pointers I allocate memory to. ANy help would be great. Thanks in advance

As part of the quick replies here is the extra information requested: Hello all again, thanks for the quick answers. My code code is being run in Linux Mint 17.2 Cinamon 64 bit. I am also using the following version of gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4 and valgrind version 3.10.1. I also tried the advice given by Nate Eldredge without success. Here are some of the valgrind ouput

==25494== Conditional jump or move depends on uninitialised value(s)
==25494==    at 0x4669D7: _int_malloc (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)
==25494==    by 0x4695C5: calloc (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)
==25494==    by 0x40C1F5: initNavSolution (initNavSolutions.c:57)
==25494==    by 0x401714: nav_init (nav_init.c:35)
==25494==    by 0x40107B: main (main.c:38)
==25494==  Uninitialised value was created
==25494==    at 0x4BA9CC: brk (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)
==25494==    by 0x490C34: sbrk (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)
==25494==    by 0x454793: __libc_setup_tls (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)
==25494==    by 0x4543FD: (below main) (in /home/glonass/Documents/EclipseProjects/pyxis/bin/nav/navexe)

Thanks all in advance again

  • So see (some of) the Valgrind messages would also help. – alk Apr 20 '16 at 15:39
  • Based on standard C, I don't think you can be assured that your array is initialized to all NULL pointers; it's all bits zero, but in principle the NULL pointer could have some other representation. Maybe this is the cause of the warning? Does it help if after the calloc, you put in an explicit loop setting each element of the allocated array to NULL? – Nate Eldredge Apr 20 '16 at 15:42
  • On which platform do observe this behaviour? – alk Apr 20 '16 at 15:51
  • It would help if you could also post your `free` code since you mention that the problem seems to happen with that. Also, some code to show the context of the alloc/free calls. You may be doing the free and then still trying to use the pointer? – Craig Estey Apr 20 '16 at 21:46
  • Hi all, I just edited my previous question to add the information requested. – Damian Miralles Apr 20 '16 at 21:53
  • Can you try to turn `–track-origins` on? Memcheck will be slower, but will report more accurately. – alvits Apr 20 '16 at 23:05

1 Answers1

2

I found the error in the code. My problem was that the code was being built statically and valgrind had issues with that. After I changed everything to a dynamically link process everything worked. Thanks all!!!!