llvm / llvm/llvm-project

[X86] crash when compiling inline asm containing return 1f with -fms-compatibility

Open
#213,910 3 comments 0 reactions 1 assignee Claimed by @VachanVY View on GitHub
backend:X86 crash extension:microsoft generated by fuzzer inline-asm
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/PfKv89dfn
```cpp
void foo() {
__asm { return 1f; }
}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:6234: virtual bool {anonymous}::AsmParser::parseMSInlineAsm(std::string&, unsigned int&, unsigned int&, llvm::SmallVectorImpl >&, llvm::SmallVectorImpl >&, llvm::SmallVectorImpl >&, const llvm::MCInstrInfo*, llvm::MCInstPrinter*, llvm::MCAsmParserSemaCallback&): Assertion `Loc >= AsmStart && "Expected Loc to be at or after Start!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fms-compatibility
1. parser at end of file
2. :1:12: parsing function body 'foo'
3. :1:12: in compound statement ('{}')
#0 0x000000000441c068 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441c068)
#1 0x0000000004418f14 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4418f14)
#2 0x000000000441954c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441954c)
#3 0x0000000004358528 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007e845aa45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007e845aa9eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007e845aa4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007e845aa288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007e845aa2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007e845aa3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000004172b18 (anonymous namespace)::AsmParser::parseMSInlineAsm(std::__cxx11::basic_string, std::allocator>&, unsigned int&, unsigned int&, llvm::SmallVectorImpl>&, llvm::SmallVectorImpl, std::allocator>>&, llvm::SmallVectorImpl, std::allocator>>&, llvm::MCInstrInfo const*, llvm::MCInstPrinter*, llvm::MCAsmParserSemaCallback&) AsmParser.cpp:0:0
#11 0x0000000006e4a59b clang::Parser::ParseMicrosoftAsmStatement(clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e4a59b)
#12 0x0000000006e4c72f clang::Parser::ParseAsmStatement(bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e4c72f)
#13 0x0000000006e3aa69 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e3aa69)
#14 0x0000000006e3b5c9 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e3b5c9)
#15 0x0000000006e43ac5 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e43ac5)
#16 0x0000000006e4430a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e4430a)
#17 0x0000000006d4237d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4237d)
#18 0x0000000006d8bed6 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d8bed6)
#19 0x0000000006d367cb clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d367cb)
#20 0x0000000006d36faf clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d36faf)
#21 0x0000000006d43758 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d43758)
#22 0x0000000006d446b5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d446b5)
#23 0x0000000006d44aa0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d44aa0)
#24 0x0000000006d21bae clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d21bae)
#25 0x0000000004f1e858 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f1e858)
#26 0x000000000524c9e8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x524c9e8)
#27 0x00000000051d95ad clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51d95ad)
#28 0x000000000532137d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x532137d)
#29 0x0000000000da9a0c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda9a0c)
#30 0x0000000000da062a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#31 0x0000000000da07ad int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#32 0x0000000004f967b9 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#33 0x0000000004358964 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4358964)
#34 0x0000000004f97325 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#35 0x0000000004f4f142 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f4f142)
#36 0x0000000004f53aa7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f53aa7)
#37 0x0000000004f5e175 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f5e175)
#38 0x0000000000da5f0a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda5f0a)
#39 0x0000000000cc1dea main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc1dea)
#40 0x00007e845aa2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#41 0x00007e845aa2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#42 0x0000000000d9ffd5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9ffd5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.