This is an archive of the discontinued LLVM Phabricator instance.

Fix GSYM tests to run the yaml files and fix test failures on some machines.
ClosedPublic

Authored by clayborg on Feb 28 2020, 3:29 PM.

Details

Summary

YAML files were not being run during lit testing as there was no lit.local.cfg file. Once this was fixed, some buildbots would fail due to a StringRef that pointed to a std::string inside of a temporary llvm::Triple object. These issues are fixed here by making a local triple object that stays around long enough so the StringRef points to valid data.

Diff Detail

Event Timeline

clayborg created this revision.Feb 28 2020, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2020, 3:29 PM

These changes can easily be tested with:

./bin/llvm-lit -v ../llvm-project/llvm/test/tools/llvm-gsymutil
aadsm accepted this revision.Feb 28 2020, 4:59 PM
This revision is now accepted and ready to land.Feb 28 2020, 4:59 PM
This revision was automatically updated to reflect the committed changes.

This breaks tests on Windows: http://45.33.8.238/win/9449/step_11.txt

Please take a look, and revert for now if the fix isn't obvious.

Reverted with:

commit 5d11e7f81cb60abc94deb0c4e41c48f39ea1da1c (HEAD -> master, origin/master, origin/HEAD)
Author: Greg Clayton <gclayton@fb.com>
Date: Fri Feb 28 21:19:05 2020 -0800

Revert "Fix GSYM tests to run the yaml files and fix test failures on some machines."

This reverts commit d334ce0b5acb945d6202d0ab6a17bdca530f50c1.
clayborg reopened this revision.Feb 28 2020, 9:20 PM
This revision is now accepted and ready to land.Feb 28 2020, 9:20 PM
clayborg planned changes to this revision.Mar 2 2020, 10:15 AM

I figured out what was going on the build servers: function calls ordering in parameters lists is not defined which caused file table entries, which split string into directory and filename, to come out directory first, then basename, or basename then directory name. Should be an easy fix.

clayborg updated this revision to Diff 247714.Mar 2 2020, 12:46 PM

Fixed an issue causing buildbots to fail where strings from files in the file table could be added in an undefined order.

This revision is now accepted and ready to land.Mar 2 2020, 12:46 PM

Trying again with:

commit 57688350adea307e7bccb83b68a5b7333de31fd7 (HEAD -> master, origin/master, origin/HEAD)
Author: Greg Clayton <gclayton@fb.com>
Date: Mon Mar 2 12:40:46 2020 -0800

Fix GSYM tests to run the yaml files and fix test failures on some machines.

YAML files were not being run during lit testing as there was no lit.local.cfg file. Once this was fixed, some buildbots would fail due to a StringRef that pointed to a std::string inside of a temporary llvm::Triple object. These issues are fixed here by making a local triple object that stays around long enough so the StringRef points to valid data. Also fixed an issue where strings for files in the file table could be added in opposite order due to parameters to function calls not having a strong ordering, which caused tests to fail.
This revision was automatically updated to reflect the committed changes.
clayborg reopened this revision.Mar 2 2020, 1:09 PM
Need to conditionalize for ARM targets, this is failing on machines that don't have ARM targets.

commit e3afe5952dfa9851738887eec0a84fa5cafe07ce (HEAD -> master, origin/master, origin/HEAD)
Author: Greg Clayton <gclayton@fb.com>
Date: Mon Mar 2 13:07:58 2020 -0800

Revert "Fix GSYM tests to run the yaml files and fix test failures on some machines."

This reverts commit 57688350adea307e7bccb83b68a5b7333de31fd7.

Need to conditionalize for ARM targets, this is failing on machines that don't have ARM targets.
This revision is now accepted and ready to land.Mar 2 2020, 1:09 PM
clayborg updated this revision to Diff 247740.Mar 2 2020, 3:39 PM

Added architecture specific directories so when targets are not enabled, tests don't run.

This revision was automatically updated to reflect the committed changes.
hctim added a subscriber: hctim.Mar 4 2020, 10:04 AM

This patch broke the MSan buildbot. The MSan bot is fickle to work (as you need a sanitized libcxx), the easiest way to reproduce the issue is following these instructions.

Full MSan report with -fsanitize-memory-track-origins=2:

Uninitialized bytes in __interceptor_write at offset 24 inside [0x720000002000, 118)
==146908==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x5d94bc7 in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:712:19
    #1 0x5d94fc2 in flush_nonempty /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:219:3
    #2 0x5d94fc2 in flush /usr/local/google/home/mitchp/llvm/llvm/include/llvm/Support/raw_ostream.h:157:7
    #3 0x5d94fc2 in llvm::raw_fd_ostream::seek(unsigned long) /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:754:3
    #4 0x5d95493 in llvm::raw_fd_ostream::pwrite_impl(char const*, unsigned long, unsigned long) /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:770:3
    #5 0x567ee45 in pwrite /usr/local/google/home/mitchp/llvm/llvm/include/llvm/Support/raw_ostream.h:387:5
    #6 0x567ee45 in llvm::gsym::FileWriter::fixup32(unsigned int, unsigned long) /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/FileWriter.cpp:55:6
    #7 0x56847a4 in llvm::gsym::FunctionInfo::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp:126:7
    #8 0x566321a in llvm::gsym::GsymCreator::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:146:51
    #9 0x56619f9 in llvm::gsym::GsymCreator::save(llvm::StringRef, llvm::support::endianness) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:56:10
    #10 0x1736921 in handleObjectFile(llvm::object::ObjectFile&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:335:23
    #11 0x1726afa in handleBuffer /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:391:22
    #12 0x1726afa in handleFileConversionToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:404:10
    #13 0x1726afa in convertFileToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:422:20
    #14 0x1726afa in main /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:463:20
    #15 0x7f483a67bbba in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26bba)
    #16 0x16ac059 in _start (/usr/local/google/home/mitchp/llvm-build/msan/sanitized-clang/bin/llvm-gsymutil+0x16ac059)

  Uninitialized value was stored to memory at
    #0 0x5d8eb94 in copy_to_buffer /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:294:24
    #1 0x5d8eb94 in llvm::raw_ostream::write(char const*, unsigned long) /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:280:3
    #2 0x567ea18 in llvm::gsym::FileWriter::writeU32(unsigned int) /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/FileWriter.cpp:45:6
    #3 0x568dd27 in llvm::gsym::Header::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/Header.cpp:96:5
    #4 0x5662275 in llvm::gsym::GsymCreator::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:101:25
    #5 0x56619f9 in llvm::gsym::GsymCreator::save(llvm::StringRef, llvm::support::endianness) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:56:10
    #6 0x1736921 in handleObjectFile(llvm::object::ObjectFile&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:335:23
    #7 0x1726afa in handleBuffer /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:391:22
    #8 0x1726afa in handleFileConversionToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:404:10
    #9 0x1726afa in convertFileToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:422:20
    #10 0x1726afa in main /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:463:20
    #11 0x7f483a67bbba in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26bba)

  Uninitialized value was stored to memory at
    #0 0x567ea3a in llvm::gsym::FileWriter::writeU32(unsigned int) /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/FileWriter.cpp:44:18
    #1 0x568dd27 in llvm::gsym::Header::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/Header.cpp:96:5
    #2 0x5662275 in llvm::gsym::GsymCreator::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:101:25
    #3 0x56619f9 in llvm::gsym::GsymCreator::save(llvm::StringRef, llvm::support::endianness) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:56:10
    #4 0x1736921 in handleObjectFile(llvm::object::ObjectFile&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:335:23
    #5 0x1726afa in handleBuffer /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:391:22
    #6 0x1726afa in handleFileConversionToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:404:10
    #7 0x1726afa in convertFileToGSYM /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:422:20
    #8 0x1726afa in main /usr/local/google/home/mitchp/llvm/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp:463:20
    #9 0x7f483a67bbba in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26bba)

  Uninitialized value was created by an allocation of 'Hdr' in the stack frame of function '_ZNK4llvm4gsym11GsymCreator6encodeERNS0_10FileWriterE'
    #0 0x5661a80 in llvm::gsym::GsymCreator::encode(llvm::gsym::FileWriter&) const /usr/local/google/home/mitchp/llvm/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:59

SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/local/google/home/mitchp/llvm/llvm/lib/Support/raw_ostream.cpp:712:19 in llvm::raw_fd_ostream::write_impl(char const*, unsigned long)
Exiting

From the bot:

-- Testing: 36342 tests, 96 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: LLVM :: tools/llvm-gsymutil/X86/elf-dwarf.yaml (35798 of 36342)
******************** TEST 'LLVM :: tools/llvm-gsymutil/X86/elf-dwarf.yaml' FAILED ********************
Script:
--
: 'RUN: at line 5';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/yaml2obj /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp
: 'RUN: at line 6';   llvm-gsymutil --convert /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml --check-prefix=CONVERT
: 'RUN: at line 7';   llvm-gsymutil --address=0x400391 --address=0x4004cd /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml --check-prefix=ADDR
: 'RUN: at line 8';   llvm-gsymutil --address=0x400391 --address=0x4004cd --verbose /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml --check-prefix=ADDRV --dump-input=always
: 'RUN: at line 9';   llvm-gsymutil /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/elf-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml --check-prefix=DUMP
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml:29:12: error: CONVERT: expected string not found in input
# CONVERT: Input file: {{.*\.yaml\.tmp}}
           ^
<stdin>:1:1: note: scanning from here
Uninitialized bytes in __interceptor_write at offset 24 inside [0x720000003000, 395)
^
<stdin>:18:61: note: possible intended match here
 #15 0x7fcccffc82e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
                                                            ^

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: LLVM :: tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml (35814 of 36342)
******************** TEST 'LLVM :: tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml' FAILED ********************
Script:
--
: 'RUN: at line 9';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/yaml2obj /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp
: 'RUN: at line 10';   llvm-gsymutil --convert /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp --arch armv7 -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp.armv7.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml --check-prefix=ARMV7
: 'RUN: at line 11';   llvm-gsymutil --convert /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp --arch arm64 -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp.arm64.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml --check-prefix=ARM64
: 'RUN: at line 12';   llvm-gsymutil --convert /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/ARM_AArch64/Output/fat-macho-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml --check-prefix=FAT
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml:14:10: error: ARMV7: expected string not found in input
# ARMV7: Input file: {{.*\.yaml\.tmp}}
         ^
<stdin>:1:1: note: scanning from here
Uninitialized bytes in __interceptor_write at offset 24 inside [0x720000002000, 118)
^
<stdin>:18:61: note: possible intended match here
 #15 0x7f561e2c92e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
                                                            ^

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: LLVM :: tools/llvm-gsymutil/X86/mach-dwarf.yaml (35815 of 36342)
******************** TEST 'LLVM :: tools/llvm-gsymutil/X86/mach-dwarf.yaml' FAILED ********************
Script:
--
: 'RUN: at line 5';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/yaml2obj /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp
: 'RUN: at line 6';   llvm-gsymutil --convert /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml --check-prefix=CONVERT
: 'RUN: at line 7';   llvm-gsymutil --address=0 --address=0x100000000 --address=0x100000f90 --address=0x100000faa --address=0x200000000 /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml --check-prefix=ADDR
: 'RUN: at line 8';   llvm-gsymutil --verbose --address=0x100000000 --address=0x100000f90 --address=0x100000faa /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml --check-prefix=ADDRV
: 'RUN: at line 9';   llvm-gsymutil /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/test/tools/llvm-gsymutil/X86/Output/mach-dwarf.yaml.tmp.gsym 2>&1 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml --check-prefix=DUMP
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml:11:12: error: CONVERT: expected string not found in input
# CONVERT: Input file: {{.*\.yaml\.tmp}}
           ^
<stdin>:1:1: note: scanning from here
Uninitialized bytes in __interceptor_write at offset 24 inside [0x720000003000, 130)
^
<stdin>:18:61: note: possible intended match here
 #15 0x7fc3869db2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
                                                            ^

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

Testing Time: 124.12s
********************
Failing Tests (3):
    LLVM :: tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
    LLVM :: tools/llvm-gsymutil/X86/elf-dwarf.yaml
    LLVM :: tools/llvm-gsymutil/X86/mach-dwarf.yaml

I just need to be able to build my binary with -fsanitize=memory. Most clangs that we have installed do not support this. Is our solution to this really to create your own buildbot and run the test just like the buildbot would? Is there a toolchain I can download from somewhere? This really makes it hard to fix issues that come up.

The full report you attached was enough to see what was going on. Is there a way we can enable always reporting the full output with FileCheck on the msan bots? That would help to see the full report, as we just got the first few lines in the buildbot error message.

clayborg reopened this revision.Mar 4 2020, 7:11 PM
This revision is now accepted and ready to land.Mar 4 2020, 7:11 PM

Recommitted with

commit ffe6695acf1f011a2acda31624beee826fb68956 (HEAD -> master, origin/master, origin/HEAD)
Author: Greg Clayton <gclayton@fb.com>
Date: Wed Mar 4 19:28:24 2020 -0800

Fix buildbots with merge that didn't happen for 4050b01ba9ece02721ec496383baee219ca8cc2b.

commit 4050b01ba9ece02721ec496383baee219ca8cc2b
Author: Greg Clayton <gclayton@fb.com>
Date: Wed Mar 4 19:12:08 2020 -0800

Fix GSYM tests to run the yaml files and fix test failures on some machines.

YAML files were not being run during lit testing as there was no lit.local.cfg file. Once this was fixed, some buildbots would fail due to a StringRef that pointed to a std::string inside of a temporary llvm::Triple object. These issues are fixed here by making a local triple object that stays around long enough so the StringRef points to valid data. Fixed memory sanitizer bot bugs as well.

Differential Revision: https://reviews.llvm.org/D75390
This revision was automatically updated to reflect the committed changes.
hctim added a comment.Mar 5 2020, 8:22 AM

I just need to be able to build my binary with -fsanitize=memory. Most clangs that we have installed do not support this. Is our solution to this really to create your own buildbot and run the test just like the buildbot would? Is there a toolchain I can download from somewhere? This really makes it hard to fix issues that come up.

Building the binary with -fsanitize=memory is basically it, yes. The tricky thing about MSan is that it requires an-MSan built libcxx/libcxxabi, which which isn't trivial to bootstrap for some configurations, hence I generally just point to the "how to repro exactly the bot". :)

The full report you attached was enough to see what was going on. Is there a way we can enable always reporting the full output with FileCheck on the msan bots? That would help to see the full report, as we just got the first few lines in the buildbot error message.

I can take a look at this, but last time I looked into it there was a FileCheck limitation.

I just need to be able to build my binary with -fsanitize=memory. Most clangs that we have installed do not support this. Is our solution to this really to create your own buildbot and run the test just like the buildbot would? Is there a toolchain I can download from somewhere? This really makes it hard to fix issues that come up.

Building the binary with -fsanitize=memory is basically it, yes. The tricky thing about MSan is that it requires an-MSan built libcxx/libcxxabi, which which isn't trivial to bootstrap for some configurations, hence I generally just point to the "how to repro exactly the bot". :)

It would be great if we maybe built some toolchains to popular targets (linux and Darwin) so people to "sudo yum install clang-msan" or "brew install clang-msan" to allow debugging of these issues.

The full report you attached was enough to see what was going on. Is there a way we can enable always reporting the full output with FileCheck on the msan bots? That would help to see the full report, as we just got the first few lines in the buildbot error message.

I can take a look at this, but last time I looked into it there was a FileCheck limitation.

All it would take is to set the default for --dump-input to be "fail" by default for memory sanitizer:

--dump-input=fail

After looking at this bug further, I am wondering if the memory sanitizer should have triggered in my case. I had a structure where I didn't init all of the values in one function, and then in another function I wrote a value to this location and this is what triggered the memory sanitizer? Pseudo code:

void write32(void *ptr, uint32_t value) {
   *(uint32_t *)ptr = value; // MSAN triggered here
}
struct Header = { int a, b; };
Header H;
H.a = 0;
write32(&H.b, 12);

And this code caused msan to trigger? I would expect read from uninitialized memory to trigger, but writes?

eugenis added a subscriber: eugenis.Mar 5 2020, 4:04 PM

I just need to be able to build my binary with -fsanitize=memory. Most clangs that we have installed do not support this. Is our solution to this really to create your own buildbot and run the test just like the buildbot would? Is there a toolchain I can download from somewhere? This really makes it hard to fix issues that come up.

Building the binary with -fsanitize=memory is basically it, yes. The tricky thing about MSan is that it requires an-MSan built libcxx/libcxxabi, which which isn't trivial to bootstrap for some configurations, hence I generally just point to the "how to repro exactly the bot". :)

It would be great if we maybe built some toolchains to popular targets (linux and Darwin) so people to "sudo yum install clang-msan" or "brew install clang-msan" to allow debugging of these issues.

Yeah... simply adding msan-instrumented libcxx + libcxxabi to the default build of the toolchain and teaching clang driver to detect/link them with msan would solve ~90% of the cases.

The full report you attached was enough to see what was going on. Is there a way we can enable always reporting the full output with FileCheck on the msan bots? That would help to see the full report, as we just got the first few lines in the buildbot error message.

I can take a look at this, but last time I looked into it there was a FileCheck limitation.

All it would take is to set the default for --dump-input to be "fail" by default for memory sanitizer:

--dump-input=fail

This sounds like a very good idea. We'd want this for ASan and other tools that may add interesting information to the binary output, as well.

After looking at this bug further, I am wondering if the memory sanitizer should have triggered in my case. I had a structure where I didn't init all of the values in one function, and then in another function I wrote a value to this location and this is what triggered the memory sanitizer? Pseudo code:

void write32(void *ptr, uint32_t value) {
   *(uint32_t *)ptr = value; // MSAN triggered here
}
struct Header = { int a, b; };
Header H;
H.a = 0;
write32(&H.b, 12);

And this code caused msan to trigger? I would expect read from uninitialized memory to trigger, but writes?

No, writes should not trigger msan. Unless it's a bitfield (then that would be read-modify-write).
Perhaps ptr or value are *derived* from a something that was read from uninitialized memory?

Oh, is is possible that you've misunderstood the wording of the report?

In this report:

MemorySanitizer: use-of-uninitialized-value
...
  Uninitialized value was stored to memory at
...
  Uninitialized value was stored to memory at
...
  Uninitialized value was created by an allocation of 'Hdr' in the stack frame of function '_ZNK4llvm4gsym11GsymCreator6encodeERNS0_10FileWriterE'

only the first stack trace is the error. The rest ("stored to memory at") explain how the uninitialized data reached that code, and should be read from the bottom:

  • allocated as "Hdr" on stack
  • then a value derived from the uninitialized contents of Hdr (possibly a straight copy) was written to memory
  • then a value derived from that value was written to memory
  • then a value derived from the previous value was used as a side-effect