[llvm-bugs] [Bug 36235] New: clang crashes on valid code: Assertion `N.ugt(ArraySize) && "bounds check failed for in-bounds index"' failed.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 5 00:38:31 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36235
Bug ID: 36235
Summary: clang crashes on valid code: Assertion
`N.ugt(ArraySize) && "bounds check failed for
in-bounds index"' failed.
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: helloqirun at gmail.com
CC: llvm-bugs at lists.llvm.org
It seems to be a recent regression. Clang-3.6 to Clang-4.0.1 are able to
compile.
$ clang-trunk -v
clang version 7.0.0 (trunk 324194)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
$ clang-trunk abc.c
abc.c:1:7: warning: integer literal is too large to be represented in a signed
integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
int a[10000000000000000000][0];
^
clang-7.0: /home/absozero/trunk/llvm/tools/clang/lib/AST/ExprConstant.cpp:405:
void {anonymous}::SubobjectDesignator::adjustIndex({anonymous}::EvalInfo&,
const clang::Expr*, llvm::APSInt): Assertion `N.ugt(ArraySize) && "bounds check
failed for in-bounds index"' failed.
#0 0x00000000021aa86a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x21aa86a)
#1 0x00000000021a870e llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x21a870e)
#2 0x00000000021a8862 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x21a8862)
#3 0x00007fec8abdf330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fec8975cc37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fec89760028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fec89755bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fec89755ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000003958eef HandleLValueArrayAdjustment((anonymous
namespace)::EvalInfo&, clang::Expr const*, (anonymous namespace)::LValue&,
clang::QualType, llvm::APSInt)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3958eef)
#9 0x0000000003965792 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::LValueExprEvaluator, bool>::Visit(clang::Stmt const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3965792)
#10 0x0000000003966637 EvaluateLValue(clang::Expr const*, (anonymous
namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3966637)
#11 0x00000000009d98be (anonymous
namespace)::PointerExprEvaluator::VisitCastExpr(clang::CastExpr const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x9d98be)
#12 0x000000000396a18b clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::PointerExprEvaluator, bool>::Visit(clang::Stmt const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x396a18b)
#13 0x000000000396ae46 EvaluatePointer(clang::Expr const*, (anonymous
namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x396ae46)
#14 0x00000000039656b4 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::LValueExprEvaluator, bool>::Visit(clang::Stmt const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x39656b4)
#15 0x0000000003966637 EvaluateLValue(clang::Expr const*, (anonymous
namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3966637)
#16 0x000000000396c164 Evaluate(clang::APValue&, (anonymous
namespace)::EvalInfo&, clang::Expr const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x396c164)
#17 0x0000000003979c7a (anonymous
namespace)::IntExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3979c7a)
#18 0x0000000003967b65 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x3967b65)
#19 0x000000000396c3e8 Evaluate(clang::APValue&, (anonymous
namespace)::EvalInfo&, clang::Expr const*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x396c3e8)
#20 0x000000000396d50e EvaluateAsRValue((anonymous namespace)::EvalInfo&,
clang::Expr const*, clang::APValue&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x396d50e)
#21 0x000000000396d757 clang::Expr::EvaluateForOverflow(clang::ASTContext
const&) const (/home/absozero/trunk/root-clang/bin/clang-7.0+0x396d757)
#22 0x0000000002fb6ca4 clang::Sema::CheckForIntOverflow(clang::Expr*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2fb6ca4)
#23 0x0000000002fe07ee clang::Sema::CheckCompletedExpr(clang::Expr*,
clang::SourceLocation, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2fe07ee)
#24 0x00000000031ccb35 clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x31ccb35)
#25 0x00000000032fe5d0
clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x32fe5d0)
#26 0x0000000002e2ee16 clang::Parser::ParseExprStatement()
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2e2ee16)
#27 0x0000000002e2c87f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2e2c87f)
#28 0x0000000002e2cabf
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2e2cabf)
#29 0x0000000002e30977 clang::Parser::ParseCompoundStatementBody(bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2e30977)
#30 0x0000000002e32d59 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2e32d59)
#31 0x0000000002daf7ec
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2daf7ec)
#32 0x0000000002dcea7c clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2dcea7c)
#33 0x0000000002daaf8a
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2daaf8a)
#34 0x0000000002dab721
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.162] [clone
.constprop.186] (/home/absozero/trunk/root-clang/bin/clang-7.0+0x2dab721)
#35 0x0000000002dab76f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2dab76f)
#36 0x0000000002db0111
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2db0111)
#37 0x0000000002db109c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2db109c)
#38 0x0000000002da756b clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2da756b)
#39 0x0000000002bc40fc clang::CodeGenAction::ExecuteAction()
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x2bc40fc)
#40 0x000000000273e7fe clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x273e7fe)
#41 0x000000000270cbf6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x270cbf6)
#42 0x00000000027d2b2b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x27d2b2b)
#43 0x0000000000a77c28 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-7.0+0xa77c28)
#44 0x00000000009ee05c main
(/home/absozero/trunk/root-clang/bin/clang-7.0+0x9ee05c)
#45 0x00007fec89747f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#46 0x0000000000a73c39 _start
(/home/absozero/trunk/root-clang/bin/clang-7.0+0xa73c39)
Stack dump:
0. Program arguments: /home/absozero/trunk/root-clang/bin/clang-7.0 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name abc.c -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/home/absozero/trunk/root-clang/lib/clang/7.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/7.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 167 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/abc-35f333.o -x c abc.c
1. abc.c:2:27: current parser token '}'
2. abc.c:2:12: parsing function body 'fn1'
3. abc.c:2:12: in compound statement ('{}')
clang-7.0: error: unable to execute command: Aborted (core dumped)
clang-7.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 324194)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-7.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-7.0: note: diagnostic msg: /tmp/abc-2490be.c
clang-7.0: note: diagnostic msg: /tmp/abc-2490be.sh
clang-7.0: note: diagnostic msg:
********************
$ cat abc.c
int a[10000000000000000000][0];
void fn1() { a[1][0] = 1; }
--
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/20180205/ed52da53/attachment-0001.html>
More information about the llvm-bugs
mailing list