This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer] Fix setbuffer() interceptor (it accept size, not mode)
ClosedPublic

Authored by azat on Dec 22 2021, 10:12 AM.

Details

Summary

Fixes: 0c81a62d9d76 ("[Sanitizer] Adding setvbuf in supported platforms and other stream buffer functions")

Diff Detail

Event Timeline

azat requested review of this revision.Dec 22 2021, 10:12 AM
azat created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 10:12 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
azat updated this revision to Diff 395919.Dec 22 2021, 12:51 PM

v2: fix mode for real setbuffer()

vitalybuka added inline comments.Dec 22 2021, 4:19 PM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7860

typo j->s ?

compiler-rt/test/sanitizer_common/TestCases/Posix/setvbuf.cpp
37

I assume this test fails without fix above?

azat updated this revision to Diff 395968.Dec 22 2021, 9:30 PM

v3: fix typo and add a comment in test

azat marked 2 inline comments as done.Dec 22 2021, 9:33 PM
azat added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7860

Indeed, thanks! Fixed.

compiler-rt/test/sanitizer_common/TestCases/Posix/setvbuf.cpp
37

Yep, added a comment.

vitalybuka accepted this revision.Dec 22 2021, 10:09 PM
This revision is now accepted and ready to land.Dec 22 2021, 10:09 PM

Thanks, I am going to land it for you.

This revision was landed with ongoing or failed builds.Dec 22 2021, 10:13 PM
This revision was automatically updated to reflect the committed changes.
azat marked 2 inline comments as done.Dec 23 2021, 3:55 AM

Thanks, I am going to land it for you.

Thanks!

BTW I'm seeing some buildbot issues, but seems that it is not related to this patch?

/usr/bin/ld:/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm_build64/tools/clang/runtime/compiler-rt-bins/lib/asan/clang_rt.asan-dynamic-powerpc64.vers:1172: syntax error in VERSION script
==25139==ERROR: LeakSanitizer: detected memory leaks
...
Direct leak of 280 byte(s) in 1 object(s) allocated from:
    #0 0x554d4d8 in operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
    #1 0x60cdb1c in make_unique<lld::elf::SymbolTableSection<llvm::object::ELFType<llvm::support::little, true> >, lld::elf::StringTableSection &> /b/sanitizer-x86_64-linux-bootstra>
    #2 0x60cdb1c in void lld::elf::createSyntheticSections<llvm::object::ELFType<(llvm::support::endianness)1, true> >() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/>
    #3 0x5a8fdd7 in void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) /b/sanitizer-x86_64-linux-bootstrap-asan/>
    #4 0x5a5f628 in lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/ELF/Driver.cpp:569:7
    #5 0x5a5b118 in lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/ELF/Dri>
    #6 0x5552273 in lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/tools/lld/lld.cpp:146:13
    #7 0x555442c in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/tools/lld/lld.cpp:171:15
    #8 0x555442c in void llvm::function_ref<void ()>::callback_fn<lld::safeLldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&)::$_0>(long) /b/sanitizer-x86_64-linux-b>
    #9 0x55a4b3a in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLExtras.h:255:12
    #10 0x55a4b3a in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/CrashRecoveryCon>
    #11 0x5550d1e in lld::safeLldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/tools/lld/lld.cpp:17>
    #12 0x55512b5 in main /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/lld/tools/lld/lld.cpp:214:14
    #13 0x7f8da2a4409a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) (BuildId: 18b9a9a8c523e5cfe5b5d946d605d09242f09798)
...
==53555==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x379a9cd in begin /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/TinyPtrVector.h:186:9
    #1 0x379a9cd in lld::elf::LinkerScript::discard(lld::elf::InputSectionBase&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/LinkerScript.cpp:577:26
    #2 0x379dc04 in lld::elf::LinkerScript::processSectionCommands()::$_4::operator()(lld::elf::OutputSection*) const /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/LinkerScript.cpp:621:9
    #3 0x379ce6b in lld::elf::LinkerScript::processSectionCommands() /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/LinkerScript.cpp:670:18
    #4 0x352b3e5 in void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/Driver.cpp:2505:13
    #5 0x34f6add in lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/Driver.cpp:569:7
    #6 0x34f0990 in lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/ELF/Driver.cpp:125:11
    #7 0x2fd7ab0 in lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/tools/lld/lld.cpp:146:13
    #8 0x2fd98b1 in operator() /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/tools/lld/lld.cpp:171:15
    #9 0x2fd98b1 in void llvm::function_ref<void ()>::callback_fn<lld::safeLldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&)::$_0>(long) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/STLExtras.h:232:12
    #10 0x302bfd6 in operator() /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/STLExtras.h:255:12
    #11 0x302bfd6 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:425:3
    #12 0x2fd5dd7 in lld::safeLldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/tools/lld/lld.cpp:170:14
    #13 0x2fd644f in main /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/lld/tools/lld/lld.cpp:214:14
    #14 0x7f14c618509a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) (BuildId: 18b9a9a8c523e5cfe5b5d946d605d09242f09798)
    #15 0x2f438b9 in _start (/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld+0x2f438b9)