<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 - [AsmParser] invalid label arithmetic with intel_syntax triggers assertion"
href="https://bugs.llvm.org/show_bug.cgi?id=50416">50416</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AsmParser] invalid label arithmetic with intel_syntax triggers assertion
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fabian.ritter@cs.uni-saarland.de
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>When using `.intel_syntax` and providing the assembly of an instruction with
malformed label arithmetic, e.g. `jb foo+`, llvm-mc triggers an assertion in
x86AsmParser::InfixCalculator::execute().
This also applies to other instructions that can use labels, as well as with
subtraction instead of addition.
It does not apply when the `.intel_syntax` is omitted.
Steps to Reproduce:
run `echo ".intel_syntax;jb foo+" | ./bin/llvm-mc` (adjust the path to llvm-mc
if necessary)
Actual Results:
The program prints `.text` and terminates irregularly with an assertion:
```
.text
llvm-mc: /llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:282:
int64_t {anonymous}::X86AsmParser::InfixCalculator::execute(): Assertion
`OperandStack.size() > 1 && "Too few operands."' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0. Program arguments: ./llvm-mc
#0 0x0000562eb6d758cc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
#1 0x0000562eb6d75987 PrintStackTraceSignalHandler(void*)
/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
#2 0x0000562eb6d735f3 llvm::sys::RunSignalHandlers()
/llvm/llvm-project/llvm/lib/Support/Signals.cpp:76:20
#3 0x0000562eb6d75218 SignalHandler(int)
/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f36619843c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#5 0x00007f366145c18b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 0x00007f366143b859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#7 0x00007f366143b729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#8 0x00007f366143b729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#9 0x00007f366144cf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#10 0x0000562eb6a8a712 (anonymous
namespace)::X86AsmParser::InfixCalculator::execute()
/llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:282:11
#11 0x0000562eb6a8b471 (anonymous
namespace)::X86AsmParser::IntelExprStateMachine::getImm()
/llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:468:48
#12 0x0000562eb6a94466 (anonymous
namespace)::X86AsmParser::ParseIntelOperand(llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
/llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2524:26
#13 0x0000562eb6a8ec1b (anonymous
namespace)::X86AsmParser::ParseOperand(llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
/llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1721:38
#14 0x0000562eb6a9aa62 (anonymous
namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
llvm::StringRef, llvm::SMLoc,
llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
/llvm/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:3365:7
#15 0x0000562eb6aba59a
llvm::MCTargetAsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
llvm::StringRef, llvm::AsmToken,
llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
/llvm/llvm-project/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h:404:3
#16 0x0000562eb6c460fe (anonymous
namespace)::AsmParser::parseAndMatchAndEmitTargetInstruction((anonymous
namespace)::ParseStatementInfo&, llvm::StringRef, llvm::AsmToken, llvm::SMLoc)
/llvm/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:2309:58
#17 0x0000562eb6c45fb8 (anonymous
namespace)::AsmParser::parseStatement((anonymous
namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*)
/llvm/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:2299:47
#18 0x0000562eb6c4012d (anonymous namespace)::AsmParser::Run(bool, bool)
/llvm/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:979:33
#19 0x0000562eb6a698cc AssembleInput(char const*, llvm::Target const*,
llvm::SourceMgr&, llvm::MCContext&, llvm::MCStreamer&, llvm::MCAsmInfo&,
llvm::MCSubtargetInfo&, llvm::MCInstrInfo&, llvm::MCTargetOptions const&)
/llvm/llvm-project/llvm/tools/llvm-mc/llvm-mc.cpp:314:45
#20 0x0000562eb6a6b067 main
/llvm/llvm-project/llvm/tools/llvm-mc/llvm-mc.cpp:547:24
#21 0x00007f366143d0b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#22 0x0000562eb6a68e7e _start (./llvm-mc+0x16ee7e)
[1] 21037 done echo ".intel_syntax;jb foo +" |
21038 abort (core dumped) ./llvm-mc
```
Expected Results:
The program should terminate regularly with an error and an appropriate error
message.
Build Date: 2021-05-20
Additional Builds and Platforms:
Also occurs with a build using the release12 branch.</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>