[llvm-bugs] [Bug 31292] New: llvm::APFloat Assertion `lost_fraction == lfExactlyZero' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 6 03:00:32 PST 2016


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

            Bug ID: 31292
           Summary: llvm::APFloat Assertion `lost_fraction ==
                    lfExactlyZero' failed.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: dan at su-root.co.uk
                CC: andrew.kaylor at intel.com, david.l.kreitzer at intel.com,
                    geek4civic at gmail.com, hfinkel at anl.gov,
                    llvm-bugs at lists.llvm.org, scanon at apple.com
    Classification: Unclassified

Created attachment 17723
  --> https://llvm.org/bugs/attachment.cgi?id=17723&action=edit
Source file that will cause assertion to fire in Clang

An assertion can be triggered in LLVM's APFloat during constant folding.

This is likely due to giving it an "unnormal" x87 fp80 constant. These types of
number were supported on early Intel math coprocessors but from the 387 on
wards they are invalid operands.

I'm going to write another bug report about this because the problem here is
much larger that just handling "unnormal" constants.

However despite this we shouldn't be able to trigger an assertion in Clang like
this.

```
clang-4.0: /home/dan/dev/llvm-upstream/src/lib/Support/APFloat.cpp:1260:
llvm::APFloatBase::opStatus
llvm::detail::IEEEFloat::normalize(llvm::APFloatBase::roundingMode,
llvm::lostFraction): Assertion `lost_fraction == lfExactlyZero' failed.
#0 0x0000000001345bf5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/dan/dev/llvm-upstream/src/lib/Support/Unix/Signals.inc:406:0
#1 0x0000000001343a5e llvm::sys::RunSignalHandlers()
/home/dan/dev/llvm-upstream/src/lib/Support/Signals.cpp:45:0
#2 0x0000000001343bac SignalHandler(int)
/home/dan/dev/llvm-upstream/src/lib/Support/Unix/Signals.inc:256:0
#3 0x00007f8b1e39d080 __restore_rt (/usr/lib/libpthread.so.0+0x11080)
#4 0x00007f8b1cef004f __GI_raise (/usr/lib/libc.so.6+0x3304f)
#5 0x00007f8b1cef147a __GI_abort (/usr/lib/libc.so.6+0x3447a)
#6 0x00007f8b1cee8ea7 __assert_fail_base (/usr/lib/libc.so.6+0x2bea7)
#7 0x00007f8b1cee8f52 (/usr/lib/libc.so.6+0x2bf52)
#8 0x00000000012d2648
llvm::detail::IEEEFloat::normalize(llvm::APFloatBase::roundingMode,
llvm::lostFraction)
/home/dan/dev/llvm-upstream/src/lib/Support/APFloat.cpp:1277:0
#9 0x00000000012d2cde
llvm::detail::IEEEFloat::addOrSubtract(llvm::detail::IEEEFloat const&,
llvm::APFloatBase::roundingMode, bool)
/home/dan/dev/llvm-upstream/src/lib/Support/APFloat.cpp:1612:0
#10 0x0000000000ee0cc1 llvm::APFloat::add(llvm::APFloat const&,
llvm::APFloatBase::roundingMode)
/home/dan/dev/llvm-upstream/src/include/llvm/ADT/APFloat.h:888:0
#11 0x0000000000ee0cc1 llvm::ConstantFoldBinaryInstruction(unsigned int,
llvm::Constant*, llvm::Constant*)
/home/dan/dev/llvm-upstream/src/lib/IR/ConstantFold.cpp:1191:0
#12 0x0000000000efff0e llvm::ConstantExpr::get(unsigned int, llvm::Constant*,
llvm::Constant*, unsigned int, llvm::Type*)
/home/dan/dev/llvm-upstream/src/lib/IR/Constants.cpp:1793:0
#13 0x0000000000b079ae SimplifyFAddInst(llvm::Value*, llvm::Value*,
llvm::FastMathFlags, (anonymous namespace)::Query const&, unsigned int) [clone
.isra.570]
/home/dan/dev/llvm-upstream/src/lib/Analysis/InstructionSimplify.cpp:812:0
#14 0x0000000000b07b03 llvm::SimplifyFAddInst(llvm::Value*, llvm::Value*,
llvm::FastMathFlags, llvm::DataLayout const&, llvm::TargetLibraryInfo const*,
llvm::DominatorTree const*, llvm::AssumptionCache*, llvm::Instruction const*)
/home/dan/dev/llvm-upstream/src/lib/Analysis/InstructionSimplify.cpp:973:0
#15 0x0000000000b13ca6 llvm::SimplifyInstruction(llvm::Instruction*,
llvm::DataLayout const&, llvm::TargetLibraryInfo const*, llvm::DominatorTree
const*, llvm::AssumptionCache*)
/home/dan/dev/llvm-upstream/src/lib/Analysis/InstructionSimplify.cpp:4298:0
#16 0x00000000011a6a10 (anonymous
namespace)::EarlyCSE::processNode(llvm::DomTreeNodeBase<llvm::BasicBlock>*)
/home/dan/dev/llvm-upstream/src/lib/Transforms/Scalar/EarlyCSE.cpp:675:0
#17 0x00000000011a8574 (anonymous namespace)::EarlyCSE::run()
/home/dan/dev/llvm-upstream/src/lib/Transforms/Scalar/EarlyCSE.cpp:932:0
#18 0x00000000011aa3ae ~ScopedHashTable
/home/dan/dev/llvm-upstream/src/include/llvm/ADT/ScopedHashTable.h:167:0
#19 0x00000000011aa3ae ~EarlyCSE
/home/dan/dev/llvm-upstream/src/lib/Transforms/Scalar/EarlyCSE.cpp:249:0
#20 0x00000000011aa3ae (anonymous
namespace)::EarlyCSELegacyCommonPass<false>::runOnFunction(llvm::Function&)
[clone .part.375]
/home/dan/dev/llvm-upstream/src/lib/Transforms/Scalar/EarlyCSE.cpp:1011:0
#21 0x0000000000f7022b llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/dan/dev/llvm-upstream/src/lib/IR/LegacyPassManager.cpp:1513:0
#22 0x0000000001c8da2c RunPassOnSCC
/home/dan/dev/llvm-upstream/src/lib/Analysis/CallGraphSCCPass.cpp:149:0
#23 0x0000000001c8da2c RunAllPassesOnSCC
/home/dan/dev/llvm-upstream/src/lib/Analysis/CallGraphSCCPass.cpp:417:0
#24 0x0000000001c8da2c (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
/home/dan/dev/llvm-upstream/src/lib/Analysis/CallGraphSCCPass.cpp:473:0
#25 0x0000000000f70e81 runOnModule
/home/dan/dev/llvm-upstream/src/lib/IR/LegacyPassManager.cpp:1590:0
#26 0x0000000000f70e81 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/dan/dev/llvm-upstream/src/lib/IR/LegacyPassManager.cpp:1693:0
#27 0x00000000014cc7e4 llvm::PrettyStackTraceString::~PrettyStackTraceString()
/home/dan/dev/llvm-upstream/src/include/llvm/Support/PrettyStackTrace.h:51:0
#28 0x00000000014cc7e4 EmitAssembly
/home/dan/dev/llvm-upstream/src/tools/clang/lib/CodeGen/BackendUtil.cpp:720:0
#29 0x00000000014cc7e4 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/dan/dev/llvm-upstream/src/tools/clang/lib/CodeGen/BackendUtil.cpp:795:0
#30 0x0000000001ada380 std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >::~unique_ptr()
/usr/include/c++/6.2.1/bits/unique_ptr.h:235:0
#31 0x0000000001ada380
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/dan/dev/llvm-upstream/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:228:0
#32 0x0000000001eb23b8
std::enable_if<std::__and_<std::is_move_constructible<bool>,
std::is_move_assignable<bool> >::value, void>::type std::swap<bool>(bool&,
bool&) /usr/include/c++/6.2.1/bits/move.h:192:0
#33 0x0000000001eb23b8 clang::ParseAST(clang::Sema&, bool, bool)
/home/dan/dev/llvm-upstream/src/tools/clang/lib/Parse/ParseAST.cpp:161:0
#34 0x0000000001ad4dc7 clang::CodeGenAction::ExecuteAction()
/home/dan/dev/llvm-upstream/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:909:0
#35 0x00000000017fe0ee clang::FrontendAction::Execute()
/home/dan/dev/llvm-upstream/src/tools/clang/lib/Frontend/FrontendAction.cpp:458:0
#36 0x00000000017d17d6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/dan/dev/llvm-upstream/src/tools/clang/lib/Frontend/CompilerInstance.cpp:886:0
#37 0x0000000001882852
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/dan/dev/llvm-upstream/src/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:0
#38 0x00000000008e3528 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/dan/dev/llvm-upstream/src/tools/clang/tools/driver/cc1_main.cpp:221:0
#39 0x00000000008a7e7b ExecuteCC1Tool
/home/dan/dev/llvm-upstream/src/tools/clang/tools/driver/driver.cpp:299:0
#40 0x00000000008a7e7b main
/home/dan/dev/llvm-upstream/src/tools/clang/tools/driver/driver.cpp:380:0
#41 0x00007f8b1cedd291 __libc_start_main (/usr/lib/libc.so.6+0x20291)
#42 0x00000000008e04ea _start
(/home/dan/dev/llvm-upstream/build/bin/clang-4.0+0x8e04ea)
Stack dump:
0.      Program arguments: /home/dan/dev/llvm-upstream/build/bin/clang-4.0 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
crash_clang34.cpp -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/home/dan/dev/llvm-upstream/build/bin/../lib/clang/4.0.0 -internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1
-internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/backward
-internal-isystem /usr/local/include -internal-isystem
/home/dan/dev/llvm-upstream/build/bin/../lib/clang/4.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdeprecated-macro -fdebug-compilation-dir
/home/dan/dev/klee-afr/src/utils/hacks/fp_test -ferror-limit 19
-fmessage-length 211 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/crash_clang34-47fb10.o -x c++ crash_clang34.cpp
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'crash_clang34.cpp'.
4.      Running pass 'Early CSE' on function '@main'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 288723) (llvm/trunk 288727)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dan/dev/llvm-upstream/build/bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-4.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-4.0: note: diagnostic msg: /tmp/crash_clang34-5a7d01.cpp
clang-4.0: note: diagnostic msg: /tmp/crash_clang34-5a7d01.sh
clang-4.0: note: diagnostic msg:

********************
```

-- 
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/20161206/55286085/attachment-0001.html>


More information about the llvm-bugs mailing list