[llvm-bugs] [Bug 50416] New: [AsmParser] invalid label arithmetic with intel_syntax triggers assertion

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 20 04:00:59 PDT 2021


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

            Bug ID: 50416
           Summary: [AsmParser] invalid label arithmetic with intel_syntax
                    triggers assertion
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: fabian.ritter at cs.uni-saarland.de
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

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 https://bugs.llvm.org/ 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.

-- 
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/20210520/0f7b9206/attachment.html>


More information about the llvm-bugs mailing list