<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94446>94446</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"SmallVector unable to grow" reached via parseIntelOperand with rejectable asm
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
workingjubilee
</td>
</tr>
</table>
<pre>
Source IR:
```llvmir
source_filename = "example.c93a12df09c9e7ea-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
module asm ".intel_syntax"
module asm "i-"
module asm ".att_syntax"
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{!"rustc version 1.80.0-nightly (a330e4959 2024-06-04)"}
```
<details><summary>Stack trace</summary>
```
LLVM ERROR: SmallVector unable to grow. Requested capacity (4294967296) is larger than maximum value for size type (4294967295)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel <source>
#0 0x00000000036ffd18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x36ffd18)
#1 0x00000000036fd68c SignalHandler(int) Signals.cpp:0:0
#2 0x000073a021242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000073a0212969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x000073a021242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x000073a0212287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000000000072f886 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
#7 0x0000000003677a16 report_size_overflow(unsigned long, unsigned long) (.constprop.0) SmallVector.cpp:0:0
#8 0x0000000003677b69 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3677b69)
#9 0x00000000009c5484 (anonymous namespace)::X86AsmParser::InfixCalculator::execute() X86AsmParser.cpp:0:0
#10 0x00000000009d9bfa (anonymous namespace)::X86AsmParser::parseIntelOperand(llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand, std::default_delete<llvm::MCParsedAsmOperand>>>&, llvm::StringRef) X86AsmParser.cpp:0:0
#11 0x00000000009de94c (anonymous namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&, llvm::StringRef, llvm::SMLoc, llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand, std::default_delete<llvm::MCParsedAsmOperand>>>&) X86AsmParser.cpp:0:0
#12 0x0000000004535842 (anonymous namespace)::AsmParser::parseAndMatchAndEmitTargetInstruction((anonymous namespace)::ParseStatementInfo&, llvm::StringRef, llvm::AsmToken, llvm::SMLoc) AsmParser.cpp:0:0
#13 0x000000000454d01b (anonymous namespace)::AsmParser::parseStatement((anonymous namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) AsmParser.cpp:0:0
#14 0x0000000004542322 (anonymous namespace)::AsmParser::Run(bool, bool) AsmParser.cpp:0:0
#15 0x0000000002599239 llvm::AsmPrinter::emitInlineAsm(llvm::StringRef, llvm::MCSubtargetInfo const&, llvm::MCTargetOptions const&, llvm::MDNode const*, llvm::InlineAsm::AsmDialect) const (/opt/compiler-explorer/clang-trunk/bin/llc+0x2599239)
#16 0x000000000258f8fd llvm::AsmPrinter::doInitialization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x258f8fd)
#17 0x0000000002d37fb8 llvm::FPPassManager::doInitialization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d37fb8)
#18 0x0000000002d4456e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d4456e)
#19 0x00000000008483f4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x0000000000741b86 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x741b86)
#21 0x000073a021229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x000073a021229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x000000000084002e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x84002e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</details>
Technically crashing is a successful rejection of this clearly ill-formed asm. However, as assembly strings are often dumped directly into LLVM from a source language, with very little modification done, it would be nice if the assembly parser was more guarded against obviously bad inputs.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWF1v6zbS_jXMzcCGRMmydOELHydpAyTvCeLT4r0zKHEks6FIlaQcu79-QcpxLDenaXp2Fxs4skxyZp55Zjj8YNaKRiEuyOwLmV1fsd5ttVm8aPMsVPNbXwqJeFVqflisdW8qhLsnkixJdE2iJcmi4SPlrhVmaLRh2KYWEhVrEUhyDYRS3LO2kzitioTFlNdRURU4Rzapmn4aEUoHacdMgw44c0yyg-7dSX7SkmSJk47OI5IsExoe_mc8_unfsjQ8JuL0EtOcJMuY5pM6j45vKjRlr-JZOln7YRdQnBGdPLmxz7NNlk569az0i5pIofr9pFH9SWp4tpr3EoHZ1gtNhXIoN_agHNufRo7HiMl3OqbMuUvR45PGnvjpMH5aS9bYI86YzL8QGkeErvyvmMyvxzKCo3LjwfRt0OvQ6GyESCjkR32E0se7FdzjDqUHRVfgu-m5mfhClr7JPrl7Uf5i8aev386kRyDpGBuh1PTWVbBDY4VWEE_zaBpNlGi2Th6A0JwlSYRpMSuARjSdRNkkSgktvIGT3td8HbmZrDg6J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