[PATCH] D89845: Add the ability to extract the unwind rows from DWARF Call Frame Information.

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 18:57:56 PST 2021


smeenai added a comment.

Running the unit test with ASAN gives me the following. The stack trace isn't the most helpful, unfortunately, but it should hopefully be something to go on.

  ==16512==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fff6bf46fc3 at pc 0x0000034713cf bp 0x7fff6bf46900 sp 0x7fff6bf460b0
  READ of size 1 at 0x7fff6bf46fc3 thread T0
      #0 0x34713ce in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) (/data/users/smeenai/llvm-project/build/ASanUBSan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x34713ce)
      #1 0x3471a08 in bcmp (/data/users/smeenai/llvm-project/build/ASanUBSan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x3471a08)
      #2 0x35c6165 in compareMemory /home/smeenai/llvm-project/llvm/include/llvm/ADT/StringRef.h:76:14
      #3 0x35c6165 in llvm::StringRef::equals(llvm::StringRef) const /home/smeenai/llvm-project/llvm/include/llvm/ADT/StringRef.h:192:15
      #4 0x4eeb444 in operator== /home/smeenai/llvm-project/llvm/include/llvm/ADT/StringRef.h:901:16
      #5 0x4eeb444 in llvm::DWARFExpression::operator==(llvm::DWARFExpression const&) const /home/smeenai/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp:507:25
      #6 0x4e7b95e in llvm::dwarf::UnwindLocation::operator==(llvm::dwarf::UnwindLocation const&) const /home/smeenai/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:142:18
      #7 0x35e5d08 in operator==<const unsigned int, llvm::dwarf::UnwindLocation> /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_pair.h:444:51
      #8 0x35e5d08 in bool std::__equal<false>::equal<std::_Rb_tree_const_iterator<std::pair<unsigned int const, llvm::dwarf::UnwindLocation> >, std::_Rb_tree_const_iterator<std::pair<unsigned int const, llvm::dwarf::UnwindLocation> > >(std::_Rb_tree_const_iterator<std::pair<unsigned int const, llvm::dwarf::UnwindLocation> >, std::_Rb_tree_const_iterator<std::pair<unsigned int const, llvm::dwarf::UnwindLocation> >, std::_Rb_tree_const_iterator<std::pair<unsigned int const, llvm::dwarf::UnwindLocation> >) /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_algobase.h:800:22
      #9 0x35fac2b in operator==<unsigned int, llvm::dwarf::UnwindLocation, std::less<unsigned int>, std::allocator<std::pair<const unsigned int, llvm::dwarf::UnwindLocation> > > /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_map.h:1437:23
      #10 0x35fac2b in operator== /home/smeenai/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h:220:22
      #11 0x35fac2b in CmpHelperEQ<llvm::dwarf::RegisterLocations, llvm::dwarf::RegisterLocations> /home/smeenai/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1392:11
      #12 0x35fac2b in Compare<llvm::dwarf::RegisterLocations, llvm::dwarf::RegisterLocations> /home/smeenai/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1421:12
      #13 0x35fac2b in (anonymous namespace)::DWARFDebugFrame_UnwindTable_DW_CFA_expression_Test::TestBody() /home/smeenai/llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp:1318:3
      #14 0x5797598 in testing::Test::Run() /home/smeenai/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
      #15 0x579a084 in testing::TestInfo::Run() /home/smeenai/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
      #16 0x579bce3 in testing::TestCase::Run() /home/smeenai/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
      #17 0x57ace73 in testing::internal::UnitTestImpl::RunAllTests() /home/smeenai/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
      #18 0x57ac32e in testing::UnitTest::Run() /home/smeenai/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
      #19 0x5786874 in RUN_ALL_TESTS /home/smeenai/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
      #20 0x5786874 in main /home/smeenai/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
      #21 0x7f30c6215554 in __libc_start_main (/lib64/libc.so.6+0x22554)
      #22 0x33f5028 in _start (/data/users/smeenai/llvm-project/build/ASanUBSan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x33f5028)
  
  Address 0x7fff6bf46fc3 is located in stack of thread T0 at offset 1155 in frame
      #0 0x35f983f in (anonymous namespace)::DWARFDebugFrame_UnwindTable_DW_CFA_expression_Test::TestBody() /home/smeenai/llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp:1271
  
    This frame has 47 object(s):
      [32, 36) 'RegNum.addr.i'
      [48, 120) 'ref.tmp.i'
      [160, 200) 'Data.i267' (line 134)
      [240, 248) 'Offset.i' (line 136)
      [272, 488) 'TestCIE' (line 1274)
      [560, 688) 'TestFDE' (line 1278)
      [720, 736) 'agg.tmp'
      [752, 768) 'gtest_ar' (line 1290)
      [784, 785) 'ref.tmp' (line 1290)
      [800, 824) 'ref.tmp10' (line 1290)
      [864, 872) 'agg.tmp11'
      [896, 899) 'ref.tmp16' (line 1290)
      [912, 928) 'agg.tmp22'
      [944, 952) 'ref.tmp29' (line 1290)
      [976, 984) 'ref.tmp34' (line 1290)
      [1008, 1024) 'gtest_ar42' (line 1299)
      [1040, 1041) 'ref.tmp43' (line 1299)
      [1056, 1080) 'ref.tmp49' (line 1299)
      [1120, 1128) 'agg.tmp50'
      [1152, 1156) 'ref.tmp55' (line 1299) <== Memory access at offset 1155 is inside this variable
      [1168, 1176) 'ref.tmp74' (line 1299)
      [1200, 1208) 'ref.tmp79' (line 1299)
      [1232, 1280) 'VerifyLocs' (line 1305)
      [1312, 1336) 'ExprData' (line 1307)
      [1376, 1377) 'ref.tmp92' (line 1307)
      [1392, 1424) 'Expr' (line 1308)
      [1456, 1520) 'ref.tmp111' (line 1309)
      [1552, 1600) 'RowsOrErr' (line 1313)
      [1632, 1648) 'gtest_ar115' (line 1314)
      [1664, 1665) 'ref.tmp116' (line 1314)
      [1680, 1704) 'ref.tmp122' (line 1314)
      [1744, 1752) 'agg.tmp123'
      [1776, 1784) 'ref.tmp133' (line 1314)
      [1808, 1816) 'ref.tmp138' (line 1314)
      [1840, 1856) 'gtest_ar152' (line 1316)
      [1872, 1880) 'ref.tmp153' (line 1316)
      [1904, 1908) 'ref.tmp159' (line 1316)
      [1920, 1928) 'ref.tmp167' (line 1316)
      [1952, 1960) 'ref.tmp172' (line 1316)
      [1984, 2000) 'gtest_ar181' (line 1317)
      [2016, 2024) 'ref.tmp182' (line 1317)
      [2048, 2052) 'ref.tmp191' (line 1317)
      [2064, 2072) 'ref.tmp199' (line 1317)
      [2096, 2104) 'ref.tmp204' (line 1317)
      [2128, 2144) 'gtest_ar213' (line 1318)
      [2160, 2168) 'ref.tmp229' (line 1318)
      [2192, 2200) 'ref.tmp234' (line 1318)
  HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
        (longjmp and C++ exceptions *are* supported)
  SUMMARY: AddressSanitizer: stack-use-after-scope (/data/users/smeenai/llvm-project/build/ASanUBSan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x34713ce) in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long)
  Shadow bytes around the buggy address:
    0x10006d7e0da0: 00 00 00 00 00 f2 f2 f2 f2 f2 f2 f2 f2 f2 00 00
    0x10006d7e0db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f2 f2
    0x10006d7e0dc0: f2 f2 00 00 f2 f2 f8 f8 f2 f2 f8 f2 f8 f8 f8 f2
    0x10006d7e0dd0: f2 f2 f2 f2 00 f2 f2 f2 f8 f2 00 00 f2 f2 f8 f2
    0x10006d7e0de0: f2 f2 f8 f2 f2 f2 f8 f8 f2 f2 f8 f2 f8 f8 f8 f2
  =>0x10006d7e0df0: f2 f2 f2 f2 00 f2 f2 f2[f8]f2 f8 f2 f2 f2 f8 f2
    0x10006d7e0e00: f2 f2 00 00 00 00 00 00 f2 f2 f2 f2 00 00 00 f2
    0x10006d7e0e10: f2 f2 f2 f2 f8 f2 00 00 00 00 f2 f2 f2 f2 f8 f8
    0x10006d7e0e20: f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 00 00 00 00 00 00
    0x10006d7e0e30: f2 f2 f2 f2 f8 f8 f2 f2 f8 f2 f8 f8 f8 f2 f2 f2
    0x10006d7e0e40: f2 f2 00 f2 f2 f2 f8 f2 f2 f2 f8 f2 f2 f2 f8 f8
  Shadow byte legend (one shadow byte represents 8 application bytes):
    Addressable:           00
    Partially addressable: 01 02 03 04 05 06 07
    Heap left redzone:       fa
    Freed heap region:       fd
    Stack left redzone:      f1
    Stack mid redzone:       f2
    Stack right redzone:     f3
    Stack after return:      f5
    Stack use after scope:   f8
    Global redzone:          f9
    Global init order:       f6
    Poisoned by user:        f7
    Container overflow:      fc
    Array cookie:            ac
    Intra object redzone:    bb
    ASan internal:           fe
    Left alloca redzone:     ca
    Right alloca redzone:    cb
    Shadow gap:              cc


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89845/new/

https://reviews.llvm.org/D89845



More information about the llvm-commits mailing list