This is an archive of the discontinued LLVM Phabricator instance.

[MachO] Add a test for detecting reserved unit length.
ClosedPublic

Authored by ikudrin on Jan 14 2020, 5:14 AM.

Diff Detail

Event Timeline

ikudrin created this revision.Jan 14 2020, 5:14 AM
dblaikie accepted this revision.Jan 14 2020, 8:19 AM
This revision is now accepted and ready to land.Jan 14 2020, 8:19 AM
This revision was automatically updated to reflect the committed changes.
hctim added a subscriber: hctim.Jan 20 2020, 10:39 PM

This test broke the UBSan buildbot here. I've rolled it back for now, but to reproduce the issue should be as simple as adding -DLLVM_USE_SANITIZER=Undefined and running ninja check-lld or make check-lld depending on which tool you use :)

[ RUN      ] ToAtomsTest.reservedUnitLength
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:972:35: runtime error: reference binding to null pointer of type 'const lld::mach_o::normalized::Section'
    #0 0x509684 in parseDebugInfo /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:971:22
    #1 0x509684 in lld::mach_o::normalized::normalizedObjectToAtoms(lld::mach_o::MachOFile*, lld::mach_o::normalized::NormalizedFile const&, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1553:18
    #2 0x50a6f5 in objectToAtoms /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1405:17
    #3 0x50a6f5 in lld::mach_o::normalized::normalizedToAtoms(lld::mach_o::normalized::NormalizedFile const&, llvm::StringRef, bool) /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1626:12
    #4 0x45811f in ToAtomsTest_reservedUnitLength_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp:126:31
    #5 0x4d250b in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
    #6 0x4d31fa in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #7 0x4d3bc2 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #8 0x4db1d2 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #9 0x4dac55 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
    #10 0x4cab63 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #11 0x4cab63 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
    #12 0x7fbfa7f842e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #13 0x40e909 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/tools/lld/unittests/MachOTests/lldMachOTests+0x40e909)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:972:35 in

Thank you! I'll fix that. For some reason, I did not receive the notification from the build bot.

Thank you! I'll fix that. For some reason, I did not receive the notification from the build bot.

Did this get fixed? In what revision? (it's nice to follow-up on these threads to include where the fix was made so others can check back to see if they've picked up the fix, etc)

Thank you! I'll fix that. For some reason, I did not receive the notification from the build bot.

Did this get fixed? In what revision? (it's nice to follow-up on these threads to include where the fix was made so others can check back to see if they've picked up the fix, etc)

The fix commit references this review, so it is mentioned in the header, in Detail/Commits section. Well, maybe that is not that clear as I expected. https://reviews.llvm.org/rG6b4f86f65f165249cbea1d23611ac97aeec7a082

Thank you! I'll fix that. For some reason, I did not receive the notification from the build bot.

Did this get fixed? In what revision? (it's nice to follow-up on these threads to include where the fix was made so others can check back to see if they've picked up the fix, etc)

The fix commit references this review, so it is mentioned in the header, in Detail/Commits section. Well, maybe that is not that clear as I expected. https://reviews.llvm.org/rG6b4f86f65f165249cbea1d23611ac97aeec7a082

Ah, indeed - thanks for the pointers!