<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61949>61949</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[debuginfo-analyzer] VLAs cause debuginfo-analyzer to crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
CarlosAlbertoEnciso
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jmorse
</td>
</tr>
</table>
<pre>
llvm-debuginfo-analyzer does not expect to see array variables where the size is non-constant, for example in this sample:
void ext(int *, int);
int foo(int bar) {
int array[bar];
ext(array, bar);
return array[4];
}
We get this DWARF:
0x0000007a: DW_TAG_array_type
DW_AT_type (0x00000072 "int")
0x0000007f: DW_TAG_subrange_type
DW_AT_type (0x00000089 "__ARRAY_SIZE_TYPE__")
DW_AT_count (0x0000003f)
0x00000088: NULL
Where the DW_AT_count is a reference to a DW_TAG_variable in the relevant subprogram. However, llvm-debuginfo-analyzer interprets everything that's a DW_AT_count as being an unsigned constant, and crashes. This is fairly simple to fix the crash for; whether there's a way of representing a variable-length array in the logical view of the debuginfo is a question I don't know the answer to. Tested with 77308dd400a1bc . Relevant bit of stack trace:
#5 0x00007f9f90af9859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
#6 0x0000000001559b73 llvm::logicalview::LVELFReader::processOneAttribute(llvm::DWARFDie const&, unsigned long*, llvm::DWARFAbbreviationDeclaration::AttributeSpec const&)
#7 0x000000000155ae51 llvm::logicalview::LVELFReader::processOneDie(llvm::DWARFDie const&, llvm::logicalview::LVScope*, llvm::DWARFDie&)
#8 0x000000000155bac9 llvm::logicalview::LVELFReader::traverseDieAndChildren(llvm::DWARFDie&, llvm::logicalview::LVScope*, llvm::DWARFDie&)
#9 0x000000000155bb41 llvm::logicalview::LVELFReader::traverseDieAndChildren(llvm::DWARFDie&, llvm::logicalview::LVScope*, llvm::DWARFDie&)
#10 0x000000000155bb41 llvm::logicalview::LVELFReader::traverseDieAndChildren(llvm::DWARFDie&, llvm::logicalview::LVScope*, llvm::DWARFDie&)
#11 0x000000000155d440 llvm::logicalview::LVELFReader::createScopes()
#12 0x00000000014bf87d llvm::logicalview::LVReader::doLoad()
#13 0x00000000015014f8 llvm::logicalview::LVReaderHandler::createReader(llvm::StringRef, std::vector<std::unique_ptr<llvm::logicalview::LVReader, std::default_delete<llvm::logicalview::LVReader>>, std::allocator <std::unique_ptr<llvm::logicalview::LVReader, std::default_delete<llvm::logicalview::LVReader>>>>&, llvm::PointerUnion<llvm::object::ObjectFile*, llvm::pdb::PDBFile*>&, llvm::StringRef, llvm::StringRef)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV8tu2zgXfhp6cxBDImVLWnihxPHfAsHfIkkbdDYGKR7ZbBnSJSnn8vQDSopju26RDjCYGSNIJPrwu5yLQnHv1cogzsjknFB6wZ22vtICXbCXplbeEkrJZD7ibVhbN_t6b53HkbDyaab19v5MomhXyjT2jBuun57RgbTowdgA-LjBOkCw4BGBO8efYMud4kKjh4c1OoSwRvDqGUHFPeastsYHbgKhF9BYB_jI7zcaQRkIa-XBd7eEVSSZk2T4DQCwtUoCPgZCC2UCEFpFCBWRSsLOj8NjTGPtEC24I7QEkp-_RvQxnWoyOY8Rk_kOqA_o6foQejGgvMY4DK0zO4jsGIDk831ZdwgrDL3N-V11vTjhMnlMuk_OCatgfre8rf637AiW4WmD--IOP_O7ZXXbxfT3hBY7LAqE0i5TNOr_GWUTKQesSOtb4bhZ4T7zIc0eSVFGkuWyur6uvixv3v9xubz98vFyudwnHbbXtjXhcDtrfqGsKF6U_f_T1dVBSnc9to-sPHBw2KBDU2PsT_7i6aU9-35DcKhxy00A34qNsyvH78fwzj7gFl0s-c9mQJmAbuMweIihT2GtzArCmgdCc9_z7fRwDwLj99xAa7qBlLA_CNxIqB33a_RjuI39oTw0XDn9BF518xEsNOqx09xFxuEh7DxOWViji184HLgf-BPYBhx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