<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - new-delete-type-mismatch on DwarfDebugInfo"
href="https://bugs.llvm.org/show_bug.cgi?id=50601">50601</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>new-delete-type-mismatch on DwarfDebugInfo
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>MachO
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>m.gehre@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>gkm@fb.com, jezreel@gmail.com, llvm-bugs@lists.llvm.org, smeenai@fb.com
</td>
</tr></table>
<p>
<div>
<pre>Running `check-lld` on current main (8b58092de49b) with
`-DLLVM_USE_SANITIZER=Address` on gcc 7.5.0 (Ubuntu 18.04),
the test mach-o/debug-syms.yaml fails with
```
==22411==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x60400000ff10 in
thread T0:
object passed to delete has wrong type:
size of the allocated type: 48 bytes;
size of the deallocated type: 16 bytes.
#0 0x7ffff6ef99c8 in operator delete(void*, unsigned long)
(/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19c8)
#1 0x721dc68 in
std::default_delete<lld::mach_o::DebugInfo>::operator()(lld::mach_o::DebugInfo*)
const /usr/include/c++/7/bits/unique_ptr.h:78
#2 0x7213e05 in std::unique_ptr<lld::mach_o::DebugInfo,
std::default_delete<lld::mach_o::DebugInfo> >::~unique_ptr()
/usr/include/c++/7/bits/unique_ptr.h:263
#3 0x7229127 in lld::mach_o::MachOFile::~MachOFile()
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/File.h:28
#4 0x7229231 in lld::mach_o::MachOFile::~MachOFile()
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/File.h:28
#5 0x3a50f01 in lld::FileNode::~FileNode() (asanrel/bin/lld+0x3a50f01)
#6 0x74eb8b2 in lld::LinkingContext::~LinkingContext()
(asanrel/bin/lld+0x74eb8b2)
#7 0x71757b6 in lld::MachOLinkingContext::~MachOLinkingContext()
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp:171
#8 0x3a89a43 in lld::mach_o::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&) (asanrel/bin/lld+0x3a89a43)
#9 0x3733fef in main ../libraries/llvm-project/lld/tools/lld/lld.cpp:167
#10 0x7ffff47d6bf6 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
#11 0x3727029 in _start (asanrel/bin/lld+0x3727029)
0x60400000ff10 is located 0 bytes inside of 48-byte region
[0x60400000ff10,0x60400000ff40)
allocated by thread T0 here:
#0 0x7ffff6ef8448 in operator new(unsigned long)
(/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448)
#1 0x7304594 in
std::enable_if<!std::is_array<lld::mach_o::DwarfDebugInfo>::value,
std::unique_ptr<lld::mach_o::DwarfDebugInfo,
std::default_delete<lld::mach_o::DwarfDebugInfo> > >::type
llvm::make_unique<lld::mach_o::DwarfDebugInfo,
lld::mach_o::TranslationUnitSource>(lld::mach_o::TranslationUnitSource&&)
../libraries/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1070
#2 0x72ea908 in parseDebugInfo
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:982
#3 0x72f830d in
lld::mach_o::normalized::normalizedObjectToAtoms(lld::mach_o::MachOFile*,
lld::mach_o::normalized::NormalizedFile const&, bool)
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1554
#4 0x72f3083 in objectToAtoms
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1406
#5 0x72fa099 in
lld::mach_o::normalized::normalizedToAtoms(lld::mach_o::normalized::NormalizedFile
const&, llvm::StringRef, bool)
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp:1627
#6 0x734344c in
lld::mach_o::MachOYamlIOTaggedDocumentHandler::handledDocTag(llvm::yaml::IO&,
lld::File const*&) const
../libraries/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp:769
#7 0x74f3a51 in lld::Registry::handleTaggedDoc(llvm::yaml::IO&, lld::File
const*&) const (asanrel/bin/lld+0x74f3a51)
#8 0x74e4a5c in lld::(anonymous
namespace)::YAMLReader::loadFile(std::unique_ptr<llvm::MemoryBuffer,
std::default_delete<llvm::MemoryBuffer> >, lld::Registry const&) const
(asanrel/bin/lld+0x74e4a5c)
#9 0x74f30ea in lld::Registry::loadFile(std::unique_ptr<llvm::MemoryBuffer,
std::default_delete<llvm::MemoryBuffer> >) const (asanrel/bin/lld+0x74f30ea)
#10 0x3a652b7 in addFile(llvm::StringRef, lld::MachOLinkingContext&, bool,
bool) (asanrel/bin/lld+0x3a652b7)
#11 0x3a8154a in lld::mach_o::parse(llvm::ArrayRef<char const*>,
lld::MachOLinkingContext&) (asanrel/bin/lld+0x3a8154a)
#12 0x3a893b9 in lld::mach_o::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&) (asanrel/bin/lld+0x3a893b9)
#13 0x3733fef in main ../libraries/llvm-project/lld/tools/lld/lld.cpp:167
#14 0x7ffff47d6bf6 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
SUMMARY: AddressSanitizer: new-delete-type-mismatch
(/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19c8) in operator delete(void*,
unsigned long)
```
The member std::unique_ptr<DebugInfo> _debugInfo of MachOFile contains an
instance of DwarfDebugInfo. It's a derived class of DebugInfo, but DebugInfo
doesn't have a virtual destructor (see
libraries/llvm-project/lld/lib/ReaderWriter/MachO/DebugInfo.h).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>