[llvm-bugs] [Bug 43885] New: Clang crashes with assertion failure on incorrect code with VLA

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Nov 2 07:30:48 PDT 2019


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

            Bug ID: 43885
           Summary: Clang crashes with assertion failure on incorrect code
                    with VLA
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: coillol at yandex.ru
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Clang crashes with assertion failure in debug mode (on 8.0.0 version) and with
OOM in release mode (https://godbolt.org/z/FEaeqS) compiling this text:

template<typename F>
using X = int[F::foo()];

struct S {
  static int foo();
};

auto x = sizeof(X<S>);

Processing it using clang-8 with no options gives the following stacktrace:

clang-8: llvm-8.0.0.src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:2023: void
clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(clang::QualType):
Assertion `type->isVariablyModifiedType() && "Must pass variably modified type
to EmitVLASizes!"' failed.
Stack dump:
0.      Program arguments: clang/8.0.0/bin/clang-8 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
third.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu
x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir
clang/8.0.0/lib/clang/8.0.0 -internal-isystem
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3
-internal-isystem
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/x86_64-suse-linux
-internal-isystem
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/backward
-internal-isystem /usr/local/include -internal-isystem
clang/8.0.0/lib/clang/8.0.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir experimental -ferror-limit 19 -fmessage-length 211
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/third-f2adb7.o -x c++ third.cpp -faddrsig
1.      <eof> parser at end of file
2.      third.cpp:8:6: LLVM IR generation of declaration 'x'
3.      third.cpp:8:6: Generating code for declaration 'x'
 #0 0x00000000018381fa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(clang/8.0.0/bin/clang-8+0x18381fa)
 #1 0x0000000001836145 llvm::sys::RunSignalHandlers()
(clang/8.0.0/bin/clang-8+0x1836145)
 #2 0x000000000183625c SignalHandler(int) (clang/8.0.0/bin/clang-8+0x183625c)
 #3 0x00007ffff7bcf850 __restore_rt (/lib64/libpthread.so.0+0xf850)
 #4 0x00007ffff67f8875 __GI_raise (/lib64/libc.so.6+0x32875)
 #5 0x00007ffff67f9e51 __GI_abort (/lib64/libc.so.6+0x33e51)
 #6 0x00007ffff67f1740 __GI___assert_fail (/lib64/libc.so.6+0x2b740)
 #7 0x0000000001aa2565
clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(clang::QualType)
(clang/8.0.0/bin/clang-8+0x1aa2565)
 #8 0x0000000001c76fa4 (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
(clang/8.0.0/bin/clang-8+0x1c76fa4)
 #9 0x0000000001c77373
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(clang/8.0.0/bin/clang-8+0x1c77373)
#10 0x0000000001c19637
clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(clang/8.0.0/bin/clang-8+0x1c19637)
#11 0x0000000001c24966
clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(clang::VarDecl
const&, llvm::Constant*, bool) (clang/8.0.0/bin/clang-8+0x1c24966)
#12 0x0000000001c24e6c
clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function*,
clang::VarDecl const*, llvm::GlobalVariable*, bool)
(clang/8.0.0/bin/clang-8+0x1c24e6c)
#13 0x0000000001c252b6
clang::CodeGen::CodeGenModule::EmitCXXGlobalVarDeclInitFunc(clang::VarDecl
const*, llvm::GlobalVariable*, bool) (clang/8.0.0/bin/clang-8+0x1c252b6)
#14 0x0000000001acb5f1
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (clang/8.0.0/bin/clang-8+0x1acb5f1)
#15 0x0000000001ae13c1
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (clang/8.0.0/bin/clang-8+0x1ae13c1)
#16 0x0000000001ae1b53
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(clang/8.0.0/bin/clang-8+0x1ae1b53)
#17 0x0000000001ae7403
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.6983)
(clang/8.0.0/bin/clang-8+0x1ae7403)
#18 0x000000000234e22d (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(clang/8.0.0/bin/clang-8+0x234e22d)
#19 0x0000000002343b7b
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(clang/8.0.0/bin/clang-8+0x2343b7b)
#20 0x0000000002c2d3d6 clang::ParseAST(clang::Sema&, bool, bool)
(clang/8.0.0/bin/clang-8+0x2c2d3d6)
#21 0x000000000234b8cc clang::CodeGenAction::ExecuteAction()
(clang/8.0.0/bin/clang-8+0x234b8cc)
#22 0x0000000001e984ae clang::FrontendAction::Execute()
(clang/8.0.0/bin/clang-8+0x1e984ae)
#23 0x0000000001e5fd3e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(clang/8.0.0/bin/clang-8+0x1e5fd3e)
#24 0x0000000001f37fea
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(clang/8.0.0/bin/clang-8+0x1f37fea)
#25 0x0000000000a486f0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (clang/8.0.0/bin/clang-8+0xa486f0)
#26 0x00000000009e53a2 main (clang/8.0.0/bin/clang-8+0x9e53a2)
#27 0x00007ffff67e4c36 __libc_start_main (/lib64/libc.so.6+0x1ec36)
#28 0x0000000000a44569 _start
/usr/src/packages/BUILD/glibc-2.11.3/csu/../sysdeps/x86_64/elf/start.S:116:0
clang-8: error: unable to execute command: Aborted
clang-8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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/20191102/c09310e2/attachment-0001.html>


More information about the llvm-bugs mailing list