[llvm-bugs] [Bug 33873] New: llvm-dsymutil crash on rustc-produced object

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 21 01:04:19 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33873

            Bug ID: 33873
           Summary: llvm-dsymutil crash on rustc-produced object
           Product: tools
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-dwarfdump
          Assignee: unassignedbugs at nondot.org
          Reporter: mh+llvm at glandium.org
                CC: friss at apple.com, llvm-bugs at lists.llvm.org

(There doesn't seem to be a component for llvm-dsymutil, so I'm putting this in
llvm-dwarfdump ; CCing friss because he filed bug 33562, so I assume he's
maintaining dsymutil or at least related somehow and might point the right
people to this bug)

We've got llvm-dsymutil crashes happening while building Firefox. They are
fairly reproducible for a given source tree, but it doesn't happen on every new
state of the source tree we push to CI. We worked around it by making rust
produce less debug info, but it seems newer versions of the rust compiler are
going to make it happen again with that same reduced debug info level.

Anyways, I narrowed it down and have a reduced testcase. You can find the
testcase here:
https://drive.google.com/file/d/0B_wfRHd_Wd-1dHFNVm51aVV6V00/view?usp=sharing

The testcase archive linked above contains two files: a dylib and a static
library. The former refers to the latter with absolute paths, so you'll want to
extract the archive in / that will extract both files under subdirectories of
home/worker/workspace/build/src/obj-firefox/toolkit/library (they come from
Firefox CI, but I stripped down the .a to only contain the .o that causes
trouble).

The problem happens when running `llvm-dsymutil path/to/XUL`. That leads to a
null deref crash. I reproduced the crash with various versions of llvm,
including the 5.0 snapshot currently in Debian unstable, but I got a stack
trace from a debug build of 4.0.1:

#0  0x000055555568e292 in llvm::DWARFAbbreviationDeclaration::getCode
(this=0x0)
    at ../include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h:57
#1  0x00005555556793ab in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::keepDIEAndDependencies (this=0x7fffffffd660, 
    RelocMgr=..., Die=..., MyInfo=..., DMO=..., CU=..., UseODR=false)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2216
#2  0x00005555556797f2 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::lookForDIEsToKeep (this=0x7fffffffd660, RelocMgr=..., 
    Die=..., DMO=..., CU=..., Flags=5) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2294
#3  0x0000555555679679 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::keepDIEAndDependencies (this=0x7fffffffd660, 
    RelocMgr=..., Die=..., MyInfo=..., DMO=..., CU=..., UseODR=false)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2253
#4  0x00005555556797f2 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::lookForDIEsToKeep (this=0x7fffffffd660, RelocMgr=..., 
    Die=..., DMO=..., CU=..., Flags=5) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2294
#5  0x00005555556798f8 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::lookForDIEsToKeep (this=0x7fffffffd660, RelocMgr=..., 
    Die=..., DMO=..., CU=..., Flags=5) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2309
#6  0x00005555556798f8 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::lookForDIEsToKeep (this=0x7fffffffd660, RelocMgr=..., 
    Die=..., DMO=..., CU=..., Flags=5) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2309
#7  0x00005555556798f8 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::lookForDIEsToKeep (this=0x7fffffffd660, RelocMgr=..., 
    Die=..., DMO=..., CU=..., Flags=5) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2309
#8  0x0000555555679679 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::keepDIEAndDependencies (this=0x7fffffffd660, 
    RelocMgr=..., Die=..., MyInfo=..., DMO=..., CU=..., UseODR=false)
(...)

(gdb) up
#1  0x00005555556793ab in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::keepDIEAndDependencies (this=0x7fffffffd660, 
    RelocMgr=..., Die=..., MyInfo=..., DMO=..., CU=..., UseODR=false)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2216
2216      uint32_t Offset = Die.getOffset() +
getULEB128Size(Abbrev->getCode());
(gdb) list
2211    
2212      // Then we need to mark all the DIEs referenced by this DIE's
2213      // attributes as kept.
2214      DataExtractor Data = Unit.getDebugInfoExtractor();
2215      const auto *Abbrev = Die.getAbbreviationDeclarationPtr();
2216      uint32_t Offset = Die.getOffset() +
getULEB128Size(Abbrev->getCode());
2217    
2218      // Mark all DIEs referenced through atttributes as kept.
2219      for (const auto &AttrSpec : Abbrev->attributes()) {
2220        DWARFFormValue Val(AttrSpec.Form);

There's an obvious null deref on line 2216. After adding a null check and an
early return in that case between line 2215 and 2216, I get an assert crash:

llvm-dsymutil:
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2388:
unsigned int
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::cloneDieReferenceAttribute(llvm::DIE&,
const llvm::DWARFDie&,
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::AttributeSpec, unsigned
int, const llvm::DWARFFormValue&, llvm::dsymutil::{anonymous}::CompileUnit&):
Assertion `Ref > InputDIE.getOffset()' failed.

(gdb) bt
#0  __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff67653fa in __GI_abort () at abort.c:89
#2  0x00007ffff675ce37 in __assert_fail_base (fmt=<optimized out>, 
    assertion=assertion at entry=0x555556831f3c "Ref > InputDIE.getOffset()", 
    file=file at entry=0x5555568316c8
"/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp",
line=line at entry=2388, 
    function=function at entry=0x555556839a00 <llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDieReferenceAttribute(llvm::DIE&,
llvm::DWARFDie const&, llvm::DWARFAbbreviationDeclaration::AttributeSpec,
unsigned int, llvm::DWARFFormValue const&, llvm::dsymutil::(anonymous
namespace)::CompileUnit&)::__PRETTY_FUNCTION__> "unsigned int
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::cloneDieReferenceAttribute(llvm::DIE&,
const llvm::DWARFDie&,
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::AttributeSpec, unsi"...)
at assert.c:92
#3  0x00007ffff675cee2 in __GI___assert_fail (assertion=0x555556831f3c "Ref >
InputDIE.getOffset()", 
    file=0x5555568316c8
"/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp",
line=2388, 
    function=0x555556839a00 <llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDieReferenceAttribute(llvm::DIE&,
llvm::DWARFDie const&, llvm::DWARFAbbreviationDeclaration::AttributeSpec,
unsigned int, llvm::DWARFFormValue const&, llvm::dsymutil::(anonymous
namespace)::CompileUnit&)::__PRETTY_FUNCTION__> "unsigned int
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::cloneDieReferenceAttribute(llvm::DIE&,
const llvm::DWARFDie&,
llvm::dsymutil::{anonymous}::DwarfLinker::DIECloner::AttributeSpec, unsi"...)
    at assert.c:101
#4  0x0000555555679e82 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDieReferenceAttribute (
    this=0x7fffffffd570, Die=..., InputDIE=..., AttrSpec=..., AttrSize=4,
Val=..., Unit=...)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2388
#5  0x000055555567a9ea in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneAttribute (this=0x7fffffffd570, 
    Die=..., InputDIE=..., Unit=..., Val=..., AttrSpec=..., AttrSize=4,
Info=...)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2566
#6  0x000055555567b7ca in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=73285056, OutOffset=763556, Flags=2, Die=0x55555b4d60a0)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2804
#7  0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=73285056, OutOffset=763556, Flags=2, Die=0x55555b4d5fd0)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#8  0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=73285056, OutOffset=763530, Flags=2, Die=0x55555b4d5e70)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#9  0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=0, OutOffset=763497, Flags=0, Die=0x55555b4d5500)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#10 0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=0, OutOffset=763338, Flags=0, Die=0x55555b063270)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#11 0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=0, OutOffset=519394, Flags=0, Die=0x55555aae40a0)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#12 0x000055555567bbeb in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneDIE (this=0x7fffffffd570,
InputDIE=..., 
    Unit=..., PCOffset=0, OutOffset=283591, Flags=0, Die=0x555557c7e278)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:2855
#13 0x000055555567ee7c in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::DIECloner::cloneAllCompileUnits (this=0x7fffffffd570, 
    DwarfContext=...) at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:3389
#14 0x000055555567f851 in llvm::dsymutil::(anonymous
namespace)::DwarfLinker::link (this=0x7fffffffd660, Map=...)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:3484
#15 0x0000555555680019 in llvm::dsymutil::linkDwarf (OutputFilename=...,
DM=..., Options=...)
    at
/home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/DwarfLinker.cpp:3551
#16 0x000055555564f5d9 in main (argc=2, argv=0x7fffffffdfe8)
    at /home/glandium/llvm-toolchain-4.0-4.0.1/tools/dsymutil/dsymutil.cpp:330

Removing the assert seems to work...

It doesn't look like, from the look of dwarfdump around the offsets where the
errors occur that there's something fundamentally wrong in the dwarf data, but
I haven't looked very carefully.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170721/4d17d97c/attachment-0001.html>


More information about the llvm-bugs mailing list