[llvm-bugs] [Bug 39887] New: Assembler crashes with invalid floating point literal.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 4 19:00:34 PST 2018


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

            Bug ID: 39887
           Summary: Assembler crashes with invalid floating point literal.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Core LLVM classes
          Assignee: unassignedbugs at nondot.org
          Reporter: jbush342 at gmail.com
                CC: llvm-bugs at lists.llvm.org

1. Create a file test.S that contains the following:

    .float 1e+2

2. Try to assemble with 'clang test.S'. The assembler will crash:

Assertion failed: (p != end && "Exponent has no digits"), function
readExponent, file ../lib/Support/APFloat.cpp, line 202.

The problem is with the + sign, which the assembler doesn't support (whether it
should is a different issue I guess). It should output an error rather than
asserting. The issue is that the semantics of error handling change part way
down the call stack. IEEEFloat::convertFromDecimalString returns the type
IEEEFloat::opStatus, which indicates if it could properly read the value. If it
returns an error, AsmParser::parseRealValue will bubble it up. However,
convertFromDecimalString calls interpretDecimal, which does not return any
error, and asserts if the format is incorrect (the functions it calls also
assert on format errors). 


Full backtrace:

0  clang-8                  0x000000010a28353c
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  clang-8                  0x000000010a283b39
PrintStackTraceSignalHandler(void*) + 25
2  clang-8                  0x000000010a28018e llvm::sys::RunSignalHandlers() +
990
3  clang-8                  0x000000010a284799 SignalHandler(int) + 505
4  libsystem_platform.dylib 0x00007fff62217f5a _sigtramp + 26
5  libsystem_platform.dylib 0x00007ff2c0412538 _sigtramp + 1579132408
6  libsystem_c.dylib        0x00007fff61fb51ae abort + 127
7  libsystem_c.dylib        0x00007fff61f7d1ac basename_r + 0
8  clang-8                  0x000000010a01833f llvm::readExponent(char const*,
char const*) + 111
9  clang-8                  0x000000010a0099ab llvm::interpretDecimal(char
const*, char const*, llvm::decimalInfo*) + 619
10 clang-8                  0x000000010a0093a3
llvm::detail::IEEEFloat::convertFromDecimalString(llvm::StringRef,
llvm::APFloatBase::roundingMode) + 83
11 clang-8                  0x000000010a00aeb1
llvm::detail::IEEEFloat::convertFromString(llvm::StringRef,
llvm::APFloatBase::roundingMode) + 913
12 clang-8                  0x000000010a015b88
llvm::APFloat::convertFromString(llvm::StringRef,
llvm::APFloatBase::roundingMode) + 104
13 clang-8                  0x0000000109b1f3f6 (anonymous
namespace)::AsmParser::parseRealValue(llvm::fltSemantics const&, llvm::APInt&)
+ 1542
14 clang-8                  0x0000000109b1ed54 (anonymous
namespace)::AsmParser::parseDirectiveRealValue(llvm::StringRef,
llvm::fltSemantics const&)::$_3::operator()() const + 84
15 clang-8                  0x0000000109b1ecf5 bool llvm::function_ref<bool
()>::callback_fn<(anonymous
namespace)::AsmParser::parseDirectiveRealValue(llvm::StringRef,
llvm::fltSemantics const&)::$_3>(long) + 21
16 clang-8                  0x0000000109b6abd9 llvm::function_ref<bool
()>::operator()() const + 25
17 clang-8                  0x0000000109b6ab16
llvm::MCAsmParser::parseMany(llvm::function_ref<bool ()>, bool) + 86
18 clang-8                  0x0000000109afe711 (anonymous
namespace)::AsmParser::parseDirectiveRealValue(llvm::StringRef,
llvm::fltSemantics const&) + 113
19 clang-8                  0x0000000109af4985 (anonymous
namespace)::AsmParser::parseStatement((anonymous
namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) + 9045
20 clang-8                  0x0000000109ae865e (anonymous
namespace)::AsmParser::Run(bool, bool) + 654
21 clang-8                  0x0000000108572779 ExecuteAssembler((anonymous
namespace)::AssemblerInvocation&, clang::DiagnosticsEngine&) + 29081
22 clang-8                  0x00000001085650da cc1as_main(llvm::ArrayRef<char
const*>, char const*, void*) + 2602
23 clang-8                  0x000000010854b752
ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) + 1202
24 clang-8                  0x0000000108548e7b main + 4059
25 libdyld.dylib            0x00007fff61f09015 start + 1
26 libdyld.dylib            0x0000000000000014 start + 2651811840

-- 
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/20181205/924746fc/attachment-0001.html>


More information about the llvm-bugs mailing list