[llvm-bugs] [Bug 43883] New: Clang crashes processing incorrect code with VLA

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


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

            Bug ID: 43883
           Summary: Clang crashes processing 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 (at least on 8.0.0 version)
and with segmentation fault in release mode (https://godbolt.org/z/q8E5tZ)
processing the following text:

int foo();

int main() {
  using X = int[foo()];
  struct S { S() { X x; } } s;
}

Compiling it using clang-8 with no additional options gives this stacktrace in
debug mode:

clang-8: llvm-8.0.0.src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1991:
clang::CodeGen::CodeGenFunction::VlaSizePair
clang::CodeGen::CodeGenFunction::getVLASize(const clang::VariableArrayType*):
Assertion `vlaSize && "no size for VLA!"' failed.
Stack dump:
0.      Program arguments: clang-8 -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -mrelax-all -disable-free -main-file-name example.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/example-7c9702.o -x c++ example.cpp -faddrsig
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      example.cpp:5:14: Generating code for declaration 'main()::S::S'
4.      example.cpp:5:18: LLVM IR generation of compound statement ('{}')
 #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 0x0000000001aa5b65
clang::CodeGen::CodeGenFunction::getVLASize(clang::VariableArrayType const*)
(clang/8.0.0/bin/clang-8+0x1aa5b65)
 #8 0x0000000001aa6477
clang::CodeGen::CodeGenFunction::getVLASize(clang::QualType)
(clang/8.0.0/bin/clang-8+0x1aa6477)
 #9 0x0000000001c1f505
clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&)
(clang/8.0.0/bin/clang-8+0x1c1f505)
#10 0x0000000001c1fcf7
clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&)
(clang/8.0.0/bin/clang-8+0x1c1fcf7)
#11 0x0000000001c1feeb
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&)
(clang/8.0.0/bin/clang-8+0x1c1feeb)
#12 0x0000000001c201cb clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl
const&) (clang/8.0.0/bin/clang-8+0x1c201cb)
#13 0x0000000001a5621f
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&)
(clang/8.0.0/bin/clang-8+0x1a5621f)
#14 0x0000000001a6334b
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(clang/8.0.0/bin/clang-8+0x1a6334b)
#15 0x0000000001a5f550 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>) (clang/8.0.0/bin/clang-8+0x1a5f550)
#16 0x0000000001a5fc63
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) (clang/8.0.0/bin/clang-8+0x1a5fc63)
#17 0x0000000001a5ff44
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) (clang/8.0.0/bin/clang-8+0x1a5ff44)
#18 0x0000000001a6339a
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(clang/8.0.0/bin/clang-8+0x1a6339a)
#19 0x0000000001a5f550 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>) (clang/8.0.0/bin/clang-8+0x1a5f550)
#20 0x0000000001c01fa4
clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&)
(clang/8.0.0/bin/clang-8+0x1c01fa4)
#21 0x0000000001aa81cb
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(clang/8.0.0/bin/clang-8+0x1aa81cb)
#22 0x0000000001bd4896
clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::CXXMethodDecl const*,
clang::CodeGen::StructorType) (clang/8.0.0/bin/clang-8+0x1bd4896)
#23 0x0000000001b21c42 (anonymous
namespace)::ItaniumCXXABI::emitCXXStructor(clang::CXXMethodDecl const*,
clang::CodeGen::StructorType) (clang/8.0.0/bin/clang-8+0x1b21c42)
#24 0x0000000001ae142d
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (clang/8.0.0/bin/clang-8+0x1ae142d)
#25 0x0000000001ae7b2b clang::CodeGen::CodeGenModule::EmitDeferred()
(clang/8.0.0/bin/clang-8+0x1ae7b2b)
#26 0x0000000001ae7b45 clang::CodeGen::CodeGenModule::EmitDeferred()
(clang/8.0.0/bin/clang-8+0x1ae7b45)
#27 0x0000000001ae7c93 clang::CodeGen::CodeGenModule::Release()
(clang/8.0.0/bin/clang-8+0x1ae7c93)
#28 0x000000000234da17 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
(clang/8.0.0/bin/clang-8+0x234da17)
#29 0x000000000234c6d6
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(clang/8.0.0/bin/clang-8+0x234c6d6)
#30 0x0000000002c2d569 clang::ParseAST(clang::Sema&, bool, bool)
(clang/8.0.0/bin/clang-8+0x2c2d569)
#31 0x000000000234b8cc clang::CodeGenAction::ExecuteAction()
(clang/8.0.0/bin/clang-8+0x234b8cc)
#32 0x0000000001e984ae clang::FrontendAction::Execute()
(clang/8.0.0/bin/clang-8+0x1e984ae)
#33 0x0000000001e5fd3e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(clang/8.0.0/bin/clang-8+0x1e5fd3e)
#34 0x0000000001f37fea
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(clang/8.0.0/bin/clang-8+0x1f37fea)
#35 0x0000000000a486f0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (clang/8.0.0/bin/clang-8+0xa486f0)
#36 0x00000000009e53a2 main (clang/8.0.0/bin/clang-8+0x9e53a2)
#37 0x00007ffff67e4c36 __libc_start_main (/lib64/libc.so.6+0x1ec36)
#38 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/bd4ad9e5/attachment-0001.html>


More information about the llvm-bugs mailing list