ramosian-glider / memory-sanitizer

Automatically exported from code.google.com/p/memory-sanitizer
0 stars 0 forks source link

Spurious uninit report from getc_unlocked() in optimized C builds #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
See file attached.

$ echo "abc" > input.txt
$ clang getc_repro.c -g -O0 -fsanitize=memory && ./a.out
a
$ clang getc_repro.c -g -O1 -fsanitize=memory && ./a.out
a
$ clang getc_repro.c -g -O2 -fsanitize=memory && ./a.out
==29518== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f19d27db064 in main /usr/include/x86_64-linux-gnu/bits/stdio.h:66
    #1 0x7f19d166076c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
    #2 0x7f19d27dae10 in _start (/usr/local/google/home/earthdok/reproducers/pango/a.out+0x7be10)

SUMMARY: MemorySanitizer: use-of-uninitialized-value 
/usr/include/x86_64-linux-gnu/bits/stdio.h:66 main
Exiting
$ clang++ getc_repro.c -g -O2 -fsanitize=memory && ./a.out
clang-3.5: warning: treating 'c' input as 'c++' when in C++ mode, this behavior 
is deprecated
a

With origins:

$ clang getc_repro.c -g -O2 -fsanitize=memory -fsanitize-memory-track-origins 
-x c++ && ./a.out
==29749== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f80385931a4 in main /usr/include/x86_64-linux-gnu/bits/stdio.h:66
    #1 0x7f803741876c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
    #2 0x7f8038592e60 in _start (/usr/local/google/home/earthdok/reproducers/pango/a.out+0x7be60)

  Uninitialized value was created by a heap allocation
    #0 0x7f80385369ed in __interceptor_malloc /usr/local/google/home/earthdok/san/llvm/projects/compiler-rt/lib/msan/msan_interceptors.cc:820
    #1 0x7f803746620a in __fopen_internal /build/buildd/eglibc-2.15/libio/../sysdeps/wordsize-64/../../libio/iofopen.c:76

SUMMARY: MemorySanitizer: use-of-uninitialized-value 
/usr/include/x86_64-linux-gnu/bits/stdio.h:66 main
Exiting

Pretty sure there's an "#ifdef __cplusplus" in stdio.h...

Original issue reported on code.google.com by earth...@google.com on 24 Apr 2014 at 8:02

Attachments:

GoogleCodeExporter commented 8 years ago
Also, I don't think the stack trace is supposed to look like that, even with 
inlining.

I'll bump priority since this is blocking us in Chrome.

Original comment by earth...@google.com on 24 Apr 2014 at 8:12

GoogleCodeExporter commented 8 years ago
(I'm talking about the line which has main() as the function name but the line 
number corresponds to getc_unlocked()).

Original comment by earth...@google.com on 24 Apr 2014 at 8:17

GoogleCodeExporter commented 8 years ago
Looking at it.
You could probably blacklist getc_unlocked to make progress.

Original comment by euge...@google.com on 25 Apr 2014 at 11:09

GoogleCodeExporter commented 8 years ago
I may have fixed this in r207224, r207227.

Original comment by euge...@google.com on 25 Apr 2014 at 2:07

GoogleCodeExporter commented 8 years ago
Adding Project:MemorySanitizer as part of GitHub migration.

Original comment by gli...@google.com on 30 Jul 2015 at 9:22