<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 - Out of memory or taking too much time in compiling an invalid decltype declaration"
href="https://bugs.llvm.org/show_bug.cgi?id=46871">46871</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Out of memory or taking too much time in compiling an invalid decltype declaration
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>haoxintu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi, all.
This invalid code makes Clang out of memory or takes too much time in
compiling. I have tested this in Clang-6.0 and upwards versions, and they
behave the same.
Input:
//small.cc
short g_const_short ;
short g_volatile_ushort ;
bool g_cv_bool ;
char g_cv_char ;
short g_cv_ushort ;
int g_cv_int ;
long g_cv_long ;
decltype(0 ? g_cv_uchar or g_var_wchar or g_var_wchar
or g_cv_uchar : g_var_int or g_cv_short or
g_volatile_bool || g_const_long or g_volatile_bool or
g_var_llong or g_const_ullong || g_cv_llong ||
g_cv_short or g_volatile_wchar ||
g_var_ushort || g_var_bool || g_const_int
|| a) var = 0;
Command:
time clang++ small.cc
Output: (in a 32G RAM, 8 cores machine)
//errors
real 0m23.615s
user 0m22.771s
sys 0m0.843s
Reproduced in Godbolt: <a href="https://godbolt.org/z/Enq96z">https://godbolt.org/z/Enq96z</a>
It says:
LLVM ERROR: out of memory
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments:
/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name example.cpp
-mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debug-info-kind=constructor -dwarf-version=4
-debugger-tuning=gdb -resource-dir
/opt/compiler-explorer/clang-trunk-20200728/lib/clang/12.0.0 -internal-isystem
/opt/compiler-explorer/gcc-9.2.0/lib/gcc/x86_64-linux-gnu/9.2.0/../../../../include/c++/9.2.0
-internal-isystem
/opt/compiler-explorer/gcc-9.2.0/lib/gcc/x86_64-linux-gnu/9.2.0/../../../../include/c++/9.2.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-9.2.0/lib/gcc/x86_64-linux-gnu/9.2.0/../../../../include/c++/9.2.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20200728/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/ce -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/example-18b01c.o -x c++ <source>
1. <source>:14:5: current parser token ')'
#0 0x0000555d8e7a9eca llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x2ceeeca)
#1 0x0000555d8e7a7c74 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x2cecc74)
#2 0x0000555d8e7a7dc3 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x2cecdc3)
#3 0x00007f1e49f6f8a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#4 0x00007f1e48e4af47 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3ef47)
#5 0x00007f1e48e4c8b1 abort (/lib/x86_64-linux-gnu/libc.so.6+0x408b1)
#6 0x0000555d8e7234a1 llvm::report_bad_alloc_error(char const*, bool)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x2c684a1)
#7 0x0000555d8e7234d5
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x2c684d5)
#8 0x00007f1e498462ac operator new(unsigned long)
(/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x932ac)
#9 0x0000555d90e5c24d llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator,
4096ul, 4096ul, 128ul>::Allocate(unsigned long, llvm::Align) (.constprop.1155)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x53a124d)
#10 0x0000555d90e639c7 clang::ImplicitCastExpr::Create(clang::ASTContext
const&, clang::QualType, clang::CastKind, clang::Expr*,
llvm::SmallVector<clang::CXXBaseSpecifier*, 4u> const*, clang::ExprValueKind)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x53a89c7)
#11 0x0000555d9070c8a9 clang::Sema::DefaultLvalueConversion(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4c518a9)
#12 0x0000555d907a83ed clang::Sema::PerformImplicitConversion(clang::Expr*,
clang::QualType, clang::StandardConversionSequence const&,
clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4ced3ed)
#13 0x0000555d907aad77 clang::Sema::PerformImplicitConversion(clang::Expr*,
clang::QualType, clang::ImplicitConversionSequence const&,
clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4cefd77)
#14 0x0000555d9097adcf
clang::Sema::PerformContextuallyConvertToBool(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4ebfdcf)
#15 0x0000555d90712740
clang::Sema::CheckLogicalOperands(clang::ActionResult<clang::Expr*, true>&,
clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation,
clang::BinaryOperatorKind)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4c57740)
#16 0x0000555d9071cd34 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation,
clang::BinaryOperatorKind, clang::Expr*, clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4c61d34)
#17 0x0000555d9071dc44 clang::Sema::BuildBinOp(clang::Scope*,
clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4c62c44)
#18 0x0000555d907ff9c2 clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformBinaryOperator(clang::BinaryOperator*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d449c2)
#19 0x0000555d907ff8bd clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformBinaryOperator(clang::BinaryOperator*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d448bd)
#20 0x0000555d907ff8bd clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformBinaryOperator(clang::BinaryOperator*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d448bd)
#21 0x0000555d907f3f3f clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformConditionalOperator(clang::ConditionalOperator*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d38f3f)
#22 0x0000555d907d09bb (anonymous
namespace)::TransformTypos::RecursiveTransformLoop(clang::Expr*, bool&)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d159bb)
#23 0x0000555d907d20ee clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, bool, llvm::function_ref<clang::ActionResult<clang::Expr*,
true> (clang::Expr*)>)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x4d170ee)
#24 0x0000555d903d7717 clang::Parser::ParseDecltypeSpecifier(clang::DeclSpec&)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x491c717)
#25 0x0000555d90405b09
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool,
clang::IdentifierInfo**, bool, bool)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x494ab09)
#26 0x0000555d903a3dfc clang::Parser::TryAnnotateCXXScopeToken(bool)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48e8dfc)
#27 0x0000555d903c9914
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x490e914)
#28 0x0000555d903a4968
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48e9968)
#29 0x0000555d903a5841
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.228)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48ea841)
#30 0x0000555d903ab719
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48f0719)
#31 0x0000555d903ace29
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48f1e29)
#32 0x0000555d903a0a69 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x48e5a69)
#33 0x0000555d8ef9bee9 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x34e0ee9)
#34 0x0000555d8ef55b4b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x349ab4b)
#35 0x0000555d8f06230b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0x35a730b)
#36 0x0000555d8c96f01c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0xeb401c)
#37 0x0000555d8c96bb1d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0xeb0b1d)
#38 0x0000555d8c8a9ba1 main
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0xdeeba1)
#39 0x00007f1e48e2db97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#40 0x0000555d8c96b69a _start
(/opt/compiler-explorer/clang-trunk-20200728/bin/clang-12+0xeb069a)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
Clang version in Godbolt:
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
8120eba5fce378083ef22651f2b7b6dcaa54a098)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
Found candidate GCC installation:
/opt/compiler-explorer/gcc-9.2.0/lib/gcc/x86_64-linux-gnu/9.2.0
Selected GCC installation:
/opt/compiler-explorer/gcc-9.2.0/lib/gcc/x86_64-linux-gnu/9.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64</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>