c - Valgrind errors caused by pclose() on Mac OS X -


i'm getting valgrind errors when attempting pclose() pipe open popen(). errors occur on mac os x, not on linux. consider following example:

#include <stdlib.h> #include <stdio.h>  int main() {   file *fp;   char buf[4096];    if (!(fp = popen("ls", "r")))     exit(-1);    while (fscanf(fp, "%s", buf) == 1)     printf("%s\n", buf);    pclose(fp);    return 0; } 

i following valgrind errors on mac (os x 10.6.7, valgrind version 3.6.0), except if remove pclose() call:

==21455== conditional jump or move depends on uninitialised value(s) ==21455==    @ 0xb1992: pclose (in /usr/lib/libsystem.b.dylib) ==21455==    0x1f16: main (in ./a.out) ==21455==  ==21455== syscall param wait4(pid) contains uninitialised byte(s) ==21455==    @ 0x504fa: wait4 (in /usr/lib/libsystem.b.dylib) ==21455==    0x1f16: main (in ./a.out) 

however, don't errors on linux system valgrind version 3.5.0.

any ideas on causing errors on mac?

update

turning on --track-origins in valgrind shows origin of problem might in popen() call. got same thing gcc 4.2.1 , 4.5.3.

==4425== conditional jump or move depends on uninitialised value(s) ==4425==    @ 0xb1992: pclose (in /usr/lib/libsystem.b.dylib) ==4425==    0x1f18: main (in ./a.out) ==4425==  uninitialised value created stack allocation ==4425==    @ 0xb14c5: popen$unix2003 (in /usr/lib/libsystem.b.dylib) ==4425==  ==4425== syscall param wait4(pid) contains uninitialised byte(s) ==4425==    @ 0x504fa: wait4 (in /usr/lib/libsystem.b.dylib) ==4425==    0x1f18: main (in ./a.out) ==4425==  uninitialised value created stack allocation ==4425==    @ 0xb14c5: popen$unix2003 (in /usr/lib/libsystem.b.dylib) 

it quite common system libraries pass uninitialized bytes system calls. less common conditional jump depend on uninitialized value, happen (glibc-2.x.supp in linux build contains 8 suppressions in glibc).

since there nothing can these errors anyway, should suppress them. see --gen-suppressions in valgrind docs.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -