Valgrind uninitialized value error [duplicate] - c

I'm sorry if i eventually do something wrong.
Ok my problem is the following:
I just coded something very easy, but when you take a look at the Valgrind error output it just confuses me.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int num1 = 100;
double num2 = 1.2;
printf("Number 1 one is: %d.\n Number two is: %f.\n", num1, num2);
return 0;
}
Valgrind error report:
$ valgrind --leak-check=full ./yaq
==50642== Memcheck, a memory error detector
==50642== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==50642== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==50642== Command: ./yaq
==50642==
--50642-- ./yaq:
--50642-- dSYM directory has wrong UUID; consider using --dsymutil=yes
==50642== Conditional jump or move depends on uninitialised value(s)
==50642== at 0x1003FCC3F: _platform_memchr$VARIANT$Haswell (in /usr/lib/system/libsystem_platform.dylib)
==50642== by 0x1001F0B96: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x1001FAFE5: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x1002209AE: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x100220C80: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x1001F6B71: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x1001F49D7: printf (in /usr/lib/system/libsystem_c.dylib)
==50642== by 0x100000F32: main (in ./yaq)
==50642==
Number 1 one is: 100.
Number two is: 1.200000.
==50642==
==50642== HEAP SUMMARY:
==50642== in use at exit: 38,673 bytes in 427 blocks
==50642== total heap usage: 510 allocs, 83 frees, 44,945 bytes.
==50642== To see them, rerun with: --leak-check=full --show-leak- kinds=all
==50642==
==50642== For counts of detected and suppressed errors, rerun with: -v
==50642== Use --track-origins=yes to see where uninitialised values come from
==50642== ERROR SUMMARY: 3 errors from 1 contexts (suppressed: 17 from 17)
Why does it say 3 errors ?
Thanks in advance.
Best regards

You may be able to see them if you run with --show-leak-kinds=all:
==96034== Memcheck, a memory error detector
==96034== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==96034== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==96034== Command: ./yaq
==96034==
--96034-- ./yaq:
--96034-- dSYM directory is missing; consider using --dsymutil=yes
==96034== Conditional jump or move depends on uninitialised value(s)
==96034== by 0x10021FCA0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F5B91: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F39F7: printf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x100000F32: main (in ./yaq)
==96034==
==96034== 80 bytes in 1 blocks are still reachable in loss record 48 of 85
==96034== at 0x10000859B: malloc (in /usr/local/Cellar/valgrind/HEAD/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==96034== by 0x1001D1756: __Balloc_D2A (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001D2075: __d2b_D2A (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001CE88B: __dtoa (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F6D72: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x10021F9CE: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x10021FCA0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F5B91: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F39F7: printf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x100000F32: main (in ./yaq)
==96034==
==96034== 4,096 bytes in 1 blocks are still reachable in loss record 85 of 85
==96034== at 0x10000859B: malloc (in /usr/local/Cellar/valgrind/HEAD/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==96034== by 0x1001F0856: __smakebuf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1002053A7: __swsetup (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x10021F77D: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x10021FCA0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F5B91: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x1001F39F7: printf (in /usr/lib/system/libsystem_c.dylib)
==96034== by 0x100000F32: main (in ./yaq)
==96034==
==96034== LEAK SUMMARY:
==96034== definitely lost: 0 bytes in 0 blocks
==96034== indirectly lost: 0 bytes in 0 blocks
==96034== possibly lost: 0 bytes in 0 blocks
==96034== still reachable: 4,244 bytes in 4 blocks
==96034== suppressed: 34,783 bytes in 425 blocks
==96034==
==96034== For counts of detected and suppressed errors, rerun with: -v
==96034== Use --track-origins=yes to see where uninitialised values come from
==96034== ERROR SUMMARY: 3 errors from 1 contexts (suppressed: 18 from 18)
Those are issues in the OS X system libraries. I suppressed them by generating this suppressions file with valgrind --leak-check=yes --show-leak-kinds=all --gen-suppressions=yes ./yaq. The output is a bit cleaner then:
$ valgrind --leak-check=yes --show-leak-kinds=all --suppressions=yaq.supp ./yaq [7:47:49]
==96285== Memcheck, a memory error detector
==96285== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==96285== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==96285== Command: ./yaq
==96285==
--96285-- ./yaq:
--96285-- dSYM directory is missing; consider using --dsymutil=yes
Number 1 one is: 100.
Number two is: 1.200000.
==96285==
==96285== HEAP SUMMARY:
==96285== in use at exit: 39,027 bytes in 429 blocks
==96285== total heap usage: 510 allocs, 81 frees, 45,171 bytes allocated
==96285==
==96285== LEAK SUMMARY:
==96285== definitely lost: 0 bytes in 0 blocks
==96285== indirectly lost: 0 bytes in 0 blocks
==96285== possibly lost: 0 bytes in 0 blocks
==96285== still reachable: 0 bytes in 0 blocks
==96285== suppressed: 39,027 bytes in 429 blocks
==96285==
==96285== For counts of detected and suppressed errors, rerun with: -v
==96285== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 21 from 19)

Valgrind support on OS X is currently being actively worked on. Your best approach is to ensure you are using a SVN trunk build, and update frequently.
The errors Valgrind is reporting to you are present within the OS X system libraries. These are not the fault of your program, but because even simple programs including these system libraries Valgrind continues to pick them up. Suppressions within Valgrind trunk are continually being updated to catch these issues, allowing you to focus on the real problems that may be present within your code.
The following commands will allow you to use Valgrind trunk, if you're not already:
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
cd valgrind
./autogen.sh
./configure
make -j4
sudo make install

Related

Valgrind reports snprintf memory leak [duplicate]

This question already has answers here:
Valgrind showing memory leak for printf and unused blocks
(2 answers)
Valgrind reports errors for a very simple C program
(3 answers)
Closed 6 years ago.
This simple program
///test.c
#include <stdio.h>
int main(){
double d = 13.37;
char buf[128];
snprintf(buf, 128, "%f", d);
return 0;
}
is leaking memory according to valgrind, the valgrind output when run
with --leak-check=full is
==29114== Memcheck, a memory error detector
==29114== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==29114== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==29114== Command: ./test
==29114==
==29114==
==29114== HEAP SUMMARY:
==29114== in use at exit: 22,175 bytes in 187 blocks
==29114== total heap usage: 263 allocs, 76 frees, 28,271 bytes allocated
==29114==
==29114== 148 (80 direct, 68 indirect) bytes in 1 blocks are definitely lost in loss record 43 of 66
==29114== at 0x100008EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==29114== by 0x1001C34A2: __Balloc_D2A (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x1001C3DEB: __d2b_D2A (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x1001C0443: __dtoa (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x1001E907A: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x10021235C: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x1001F65A8: _vsnprintf (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x1001F665D: vsnprintf (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x100227CBF: __snprintf_chk (in /usr/lib/system/libsystem_c.dylib)
==29114== by 0x100000F4B: main (in ./test)
==29114==
==29114== LEAK SUMMARY:
==29114== definitely lost: 80 bytes in 1 blocks
==29114== indirectly lost: 68 bytes in 2 blocks
==29114== possibly lost: 0 bytes in 0 blocks
==29114== still reachable: 0 bytes in 0 blocks
==29114== suppressed: 22,027 bytes in 184 blocks
==29114==
==29114== For counts of detected and suppressed errors, rerun with: -v
==29114== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 18 from 18)
Either I'm misunderstanding something or snprintf seems to be leaking.
I'm on os x if it matters.
Edit: im interested in the "definitely lost" and "indirectly lost" memory leak not the suppressed memory (which isn't a leak).

Why do glib arrays use uninitalized memory?

I've written a toy function using pointer arrays from GLib:
#include <glib-2.0/glib.h>
#include <stdio.h>
void append_string(GArray* arr) {
g_array_append_vals(arr, "foo", 1);
}
int main() {
GPtrArray *arr = g_ptr_array_new();
append_string((GArray*)arr);
g_ptr_array_free(arr, TRUE);
return 0;
}
However, running this with valgrind gives:
==5876== Memcheck, a memory error detector
==5876== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==5876== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==5876== Command: ./demo
==5876==
==5876== Conditional jump or move depends on uninitialised value(s)
==5876== at 0x4E532E9: ??? (in /usr/lib/libglib-2.0.so.0.4800.0)
==5876== by 0x4E536A7: g_array_append_vals (in /usr/lib/libglib-2.0.so.0.4800.0)
==5876== by 0x400727: append_string (main_arrays.c:5)
==5876== by 0x400747: main (main_arrays.c:11)
==5876==
==5876== Conditional jump or move depends on uninitialised value(s)
==5876== at 0x4E532EE: ??? (in /usr/lib/libglib-2.0.so.0.4800.0)
==5876== by 0x4E536A7: g_array_append_vals (in /usr/lib/libglib-2.0.so.0.4800.0)
==5876== by 0x400727: append_string (main_arrays.c:5)
==5876== by 0x400747: main (main_arrays.c:11)
==5876==
==5876== Conditional jump or move depends on uninitialised value(s)
==5876== at 0x4E536C9: g_array_append_vals (in /usr/lib/libglib-2.0.so.0.4800.0)
==5876== by 0x400727: append_string (main_arrays.c:5)
==5876== by 0x400747: main (main_arrays.c:11)
==5876==
==5876==
==5876== HEAP SUMMARY:
==5876== in use at exit: 18,604 bytes in 6 blocks
==5876== total heap usage: 8 allocs, 2 frees, 18,652 bytes allocated
==5876==
==5876== LEAK SUMMARY:
==5876== definitely lost: 0 bytes in 0 blocks
==5876== indirectly lost: 0 bytes in 0 blocks
==5876== possibly lost: 0 bytes in 0 blocks
==5876== still reachable: 18,604 bytes in 6 blocks
==5876== suppressed: 0 bytes in 0 blocks
==5876== Rerun with --leak-check=full to see details of leaked memory
==5876==
==5876== For counts of detected and suppressed errors, rerun with: -v
==5876== Use --track-origins=yes to see where uninitialised values come from
==5876== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
Am I misusing the API, is this a bug in GLib, or is valgrind wrong? If it's a valgrind limitation, can I silence this valgrind warning whilst still having valgrind warn on genuine issues in my code?
GArray and GPtrArray are not equivalent. There's no subtyping here, even if they have same public fields.
Use g_ptr_array_add instead:
void append_string(GPtrArray* arr) {
g_ptr_array_add(arr, "foo");
}

Valgrind and gtk linking

I have came around something strange with valgrind lately. If I write for instance a simple test.c file:
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("hello\n");
}
and compile it with this command: gcc $(pkg-config --cflags --libs gtk+-3.0) -g3 -O0 and then check for memory leaks with: valgrind --leak-check=full ./a.out I get something like:
==7588== Memcheck, a memory error detector
==7588== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==7588== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==7588== Command: ./a.out
==7588==
hello
==7588==
==7588== HEAP SUMMARY:
==7588== in use at exit: 51,837 bytes in 245 blocks
==7588== total heap usage: 1,551 allocs, 1,306 frees, 394,322,404 bytes allocated
==7588==
==7588== 16 bytes in 1 blocks are possibly lost in loss record 89 of 244
==7588== at 0x4C2A987: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7588== by 0x6DE35B1: g_malloc0 (in /usr/lib/libglib-2.0.so.0.4400.1)
==7588== by 0x6B70294: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B73F92: g_type_register_fundamental (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B5464B: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B4E67D: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x400F279: call_init.part.0 (in /usr/lib/ld-2.22.so)
==7588== by 0x400F38A: _dl_init (in /usr/lib/ld-2.22.so)
==7588== by 0x4000DB9: ??? (in /usr/lib/ld-2.22.so)
==7588==
==7588== 16 bytes in 1 blocks are possibly lost in loss record 90 of 244
==7588== at 0x4C28C10: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7588== by 0x4C2AADE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7588== by 0x6DE361D: g_realloc (in /usr/lib/libglib-2.0.so.0.4400.1)
==7588== by 0x6B70148: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B73F92: g_type_register_fundamental (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B5464B: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x6B4E67D: ??? (in /usr/lib/libgobject-2.0.so.0.4400.1)
==7588== by 0x400F279: call_init.part.0 (in /usr/lib/ld-2.22.so)
==7588== by 0x400F38A: _dl_init (in /usr/lib/ld-2.22.so)
==7588== by 0x4000DB9: ??? (in /usr/lib/ld-2.22.so)
==7588==
.
.
.
==7588==
==7588== LEAK SUMMARY:
==7588== definitely lost: 0 bytes in 0 blocks
==7588== indirectly lost: 0 bytes in 0 blocks
==7588== possibly lost: 1,352 bytes in 18 blocks
==7588== still reachable: 50,485 bytes in 227 blocks
==7588== of which reachable via heuristic:
==7588== newarray : 1,536 bytes in 16 blocks
==7588== suppressed: 0 bytes in 0 blocks
==7588== Reachable blocks (those to which a pointer was found) are not shown.
==7588== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==7588==
==7588== For counts of detected and suppressed errors, rerun with: -v
==7588== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0)
Whereas if I compile it normally, with: gcc -g3 -O0 test.c and then check for memory leaks with: valgrind --leak-check=full ./a.out, I obviously don't get any memory leaks:
==7734== Memcheck, a memory error detector
==7734== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==7734== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==7734== Command: ./a.out
==7734==
hello
==7734==
==7734== HEAP SUMMARY:
==7734== in use at exit: 0 bytes in 0 blocks
==7734== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==7734==
==7734== All heap blocks were freed -- no leaks are possible
==7734==
==7734== For counts of detected and suppressed errors, rerun with: -v
==7734== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
So my question is: why does linking gtk generate so many memory leaks ?
Thank you very much in advance

Valgrind is telling me I have error and possible memory leak in this simple C program [duplicate]

This question already has answers here:
Valgrind reports errors for a very simple C program
(3 answers)
Closed 7 years ago.
The challenge is to clear all Valgrind errors before going on to the next lesson, but I don't really know what's wrong with this program. I want to know what's wrong before going on. Thanks, appreciate the help.
#include <stdio.h>
int main()
{
int age = 10;
int height = 72;
printf("I am %d years old.\n", age);
printf("I am %d inches tall.\n", height);
return 0;
}
Here's the valgrind report:
==41714== Memcheck, a memory error detector
==41714== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==41714== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==41714== Command: ./ex3
==41714==
==41714== Conditional jump or move depends on uninitialised value(s)
==41714== at 0x1003FBC3F: _platform_memchr$VARIANT$Haswell (in /usr/lib/system/libsystem_platform.dylib)
==41714== by 0x1001EFBB6: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x1001FA005: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x10021F9CE: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x10021FCA0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x1001F5B91: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x1001F39F7: printf (in /usr/lib/system/libsystem_c.dylib)
==41714== by 0x100000F4D: main (ex3.c:8)
==41714==
I am 10 years old.
I am 72 inches tall.
==41714==
==41714== HEAP SUMMARY:
==41714== in use at exit: 38,816 bytes in 426 blocks
==41714== total heap usage: 507 allocs, 81 frees, 44,960 bytes allocated
==41714==
==41714== LEAK SUMMARY:
==41714== definitely lost: 0 bytes in 0 blocks
==41714== indirectly lost: 0 bytes in 0 blocks
==41714== possibly lost: 0 bytes in 0 blocks
==41714== still reachable: 4,096 bytes in 1 blocks
==41714== suppressed: 34,720 bytes in 425 blocks
==41714== Rerun with --leak-check=full to see details of leaked memory
==41714==
==41714== For counts of detected and suppressed errors, rerun with: -v
==41714== Use --track-origins=yes to see where uninitialised values come from
==41714== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
There are very clearly no memory issues. You never even malloc or free anything, so at this point all memory is handled without you being involved. This must be an issue with the Valgrind. If you are using OSX perhaps try on a machine with linux if you have one available.

uninitialised value(s) - if_nan function

I have a code that calls the following function
int if_nan(double a)
{
return a!=a;
}
to find if_nan() is encountered in calculations. When I do memcheck with Valgrind, I get the following error:
==3484== Conditional jump or move depends on uninitialised value(s)
==3484== at 0x804B0A9: if_nan (sph.c:71)
==3484== by 0x8051B78: pressure_forces (pressure_force.c:21)
...
I don't understand what value to be initialized here. Please suggest a way to avoid this error. Thank You
And we don't understand what you want from us by posting 1/100th of your code !!!
Howver, check the below part for your clarification. And please , from next time, try to put the entire code here. Its free of cost. :-)
Case 1
code
#include <stdio.h>
#include <stdlib.h>
int if_nan(double a)
{
return a!=a;
}
int main()
{
double p;
int result;
p = 3.5;
result = if_nan(p);
printf("\n\nresult is %d\n\n", result);
return 0;
}
O/P
[sourav#localhost ~]$ gcc -g so_test3.c -o test
[sourav#localhost ~]$ valgrind --leak-check=full ./test
==24217== Memcheck, a memory error detector
==24217== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==24217== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==24217== Command: ./test
==24217==
result is 0
==24217==
==24217== HEAP SUMMARY:
==24217== in use at exit: 0 bytes in 0 blocks
==24217== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==24217==
==24217== All heap blocks were freed -- no leaks are possible
==24217==
==24217== For counts of detected and suppressed errors, rerun with: -v
==24217== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 12 from 8)
[sourav#localhost ~]$
Case 2
Code
#include <stdio.h>
#include <stdlib.h>
int if_nan(double a)
{
return a!=a;
}
int main()
{
double p;
int result;
//p = 3.5;
result = if_nan(p);
printf("\n\nresult is %d\n\n", result);
return 0;
}
O/P
[sourav#localhost ~]$ gcc -g so_test3.c -o test
[sourav#localhost ~]$ valgrind --leak-check=full ./test
==24229== Memcheck, a memory error detector
==24229== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==24229== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==24229== Command: ./test
==24229==
==24229== Use of uninitialised value of size 4
==24229== at 0x830C3B: _itoa_word (in /lib/libc-2.5.so)
==24229== by 0x8343D0: vfprintf (in /lib/libc-2.5.so)
==24229== by 0x83BE82: printf (in /lib/libc-2.5.so)
==24229== by 0x80483DF: main (so_test3.c:17)
==24229==
==24229== Conditional jump or move depends on uninitialised value(s)
==24229== at 0x830C43: _itoa_word (in /lib/libc-2.5.so)
==24229== by 0x8343D0: vfprintf (in /lib/libc-2.5.so)
==24229== by 0x83BE82: printf (in /lib/libc-2.5.so)
==24229== by 0x80483DF: main (so_test3.c:17)
==24229==
==24229== Conditional jump or move depends on uninitialised value(s)
==24229== at 0x8327A0: vfprintf (in /lib/libc-2.5.so)
==24229== by 0x83BE82: printf (in /lib/libc-2.5.so)
==24229== by 0x80483DF: main (so_test3.c:17)
==24229==
result is 0
==24229==
==24229== HEAP SUMMARY:
==24229== in use at exit: 0 bytes in 0 blocks
==24229== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==24229==
==24229== All heap blocks were freed -- no leaks are possible
==24229==
==24229== For counts of detected and suppressed errors, rerun with: -v
==24229== Use --track-origins=yes to see where uninitialised values come from
==24229== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 12 from 8)
[sourav#localhost ~]$
Looks familiar? :-) [No hard feelings]

Resources