Bug#794475: clang-3.6: clang segfaults on invalid use of non-static data member

Lorenz Hübschle-Schneider lorenz-dev at lgh-alumni.de
Mon Aug 3 13:11:54 UTC 2015


Package: clang-3.6
Version: 1:3.6.2~+rc1-1~exp1
Severity: normal

Dear Maintainer,

I managed to make clang-3.6 segfault on a piece of code that should not compile,
as it comprises the invalid use of a non-static data member.

This also applies to clang-3.5.

The crash is 100% reproducible and also affects clang-3.5 (1:3.5.2-1) but appears
to be fixed in clang-3.7 (1:3.7~svn239806-1+b1). It affects clang-3.6 both from
unstable (1:3.6.1-1) and experimental (1:3.6.2~+rc1-1~exp1).

Unfortunately I have not been able to isolate what causes the crash or to
produce a minimal example, and I can't share the original code (yet -- it's
unpublished research).

crash backtrace:


OMPI_CXX=clang++-3.6 mpic++ -std=c++11 -Wall -Wextra -Werror -I/opt/intel/composer_xe_2015.2.164/mkl/include  -Ofast -g -flto -DNDEBUG -o mostfreq mostfreq.cpp /usr/lib/x86_64-linux-gnu/libgsl.a libboost_mpi.a libboost_serialization.a /opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_core.a /opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_sequential.a -ldl
In file included from mostfreq.cpp:13:
../worker_ec.h:178:48: error: invalid use of non-static data member 'k'
    std::vector<element> select_dht(int rank = k) {
                                               ^
../worker_ec.h:178:41: error: unused parameter 'rank' [-Werror,-Wunused-parameter]
    std::vector<element> select_dht(int rank = k) {
                                        ^
#0 0x7f991806d3a2 llvm::sys::PrintStackTrace(_IO_FILE*) (/usr/lib/x86_64-linux-gnu/libLLVM-3.6.so.1+0xf943a2)
#1 0x7f991806baf1 (/usr/lib/x86_64-linux-gnu/libLLVM-3.6.so.1+0xf92af1)
#2 0x7f9916cb08d0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#3 0xb62721 (/usr/lib/llvm-3.6/bin/clang+0xb62721)
#4 0xb62b35 (/usr/lib/llvm-3.6/bin/clang+0xb62b35)
#5 0xb630f2 clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/usr/lib/llvm-3.6/bin/clang+0xb630f2)
#6 0xc96118 clang::Sema::BuildCXXDefaultArgExpr(clang::SourceLocation, clang::FunctionDecl*, clang::ParmVarDecl*) (/usr/lib/llvm-3.6/bin/clang+0xc96118)
#7 0xc9646c clang::Sema::GatherArgumentsForCall(clang::SourceLocation, clang::FunctionDecl*, clang::FunctionProtoType const*, unsigned int, llvm::ArrayRef<clang::Expr*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::Sema::VariadicCallType, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xc9646c)
#8 0xc97302 clang::Sema::ConvertArgumentsForCall(clang::CallExpr*, clang::Expr*, clang::FunctionDecl*, clang::FunctionProtoType const*, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/usr/lib/llvm-3.6/bin/clang+0xc97302)
#9 0xd852d9 clang::Sema::BuildCallToMemberFunction(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib/llvm-3.6/bin/clang+0xd852d9)
#10 0xc98c79 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) (/usr/lib/llvm-3.6/bin/clang+0xc98c79)
#11 0xe36a18 (/usr/lib/llvm-3.6/bin/clang+0xe36a18)
#12 0xe32645 (/usr/lib/llvm-3.6/bin/clang+0xe32645)
#13 0xe335d1 (/usr/lib/llvm-3.6/bin/clang+0xe335d1)
#14 0xe33801 (/usr/lib/llvm-3.6/bin/clang+0xe33801)
#15 0xe3fcc5 (/usr/lib/llvm-3.6/bin/clang+0xe3fcc5)
#16 0xe40c63 (/usr/lib/llvm-3.6/bin/clang+0xe40c63)
#17 0xe40d7b (/usr/lib/llvm-3.6/bin/clang+0xe40d7b)
#18 0xe3ff35 (/usr/lib/llvm-3.6/bin/clang+0xe3ff35)
#19 0xe42ddf clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-3.6/bin/clang+0xe42ddf)
#20 0xe65280 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xe65280)
#21 0xe63efb clang::Sema::PerformPendingInstantiations(bool) (/usr/lib/llvm-3.6/bin/clang+0xe63efb)
#22 0xe65365 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xe65365)
#23 0xe63efb clang::Sema::PerformPendingInstantiations(bool) (/usr/lib/llvm-3.6/bin/clang+0xe63efb)
#24 0xb157df clang::Sema::ActOnEndOfTranslationUnit() (/usr/lib/llvm-3.6/bin/clang+0xb157df)
#25 0xa68fa0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/lib/llvm-3.6/bin/clang+0xa68fa0)
#26 0xa5ecc3 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xa5ecc3)
#27 0x6efdc6 clang::FrontendAction::Execute() (/usr/lib/llvm-3.6/bin/clang+0x6efdc6)
#28 0x6cc2f9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-3.6/bin/clang+0x6cc2f9)
#29 0x6b4c43 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-3.6/bin/clang+0x6b4c43)
#30 0x6af278 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-3.6/bin/clang+0x6af278)
#31 0x6ae8a3 main (/usr/lib/llvm-3.6/bin/clang+0x6ae8a3)
#32 0x7f9915884b45 __libc_start_main /tmp/buildd/glibc-2.19/csu/libc-start.c:321:0
#33 0x6ae912 _start (/usr/lib/llvm-3.6/bin/clang+0x6ae912)
Stack dump:
0.	Program arguments: /usr/lib/llvm-3.6/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-free -disable-llvm-verifier -main-file-name mostfreq.cpp -mrelocation-model static -mthread-model posix -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -ffp-contract=fast -ffast-math -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.25 -momit-leaf-frame-pointer -g -dwarf-column-info -resource-dir /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2 -D NDEBUG -I /opt/intel/composer_xe_2015.2.164/mkl/include -I /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.1.1/../../../../include/c++/5.1.1 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.1.1/../../../../include/x86_64-linux-gnu/c++/5.1.1 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.1.1/../../../../include/x86_64-linux-gnu/c++/5.1.1 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.1.1/../../../../include/c++/5.1.1/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Ofast -Wall -Wextra -Werror -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/lorenz/coding/topk/pac -ferror-limit 19 -fmessage-length 118 -pthread -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /tmp/mostfreq-271846.o -x c++ mostfreq.cpp 
1.	<eof> parser at end of file
2.	mostfreq.cpp:23:6: instantiating function definition 'run'
3.	./worker_ec.h:71:26: instantiating function definition 'run'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Debian clang version 3.6.2-+rc1-1~exp1 (tags/RELEASE_362/rc1) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://bugs.debian.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s).



The function 'run' in worker_ec.h is the callsite of select_dht.

If there is any way in which I can help track this down, I will gladly help.

Cheers,
Lorenz

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.0.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clang-3.6 depends on:
ii  binutils                 2.25-11
ii  libc6                    2.19-19
ii  libc6-dev                2.19-19
ii  libclang-common-3.6-dev  1:3.6.2~+rc1-1~exp1
ii  libclang1-3.6            1:3.6.2~+rc1-1~exp1
ii  libedit2                 3.1-20150325-1
ii  libffi6                  3.2.1-3
ii  libgcc-4.9-dev           4.9.3-3
ii  libgcc1                  1:5.1.1-14
ii  libllvm3.6               1:3.6.2~+rc1-1~exp1
ii  libobjc-4.9-dev          4.9.3-3
ii  libstdc++-4.9-dev        4.9.3-3
ii  libstdc++6               5.1.1-14
ii  libtinfo5                5.9+20150516-2
ii  zlib1g                   1:1.2.8.dfsg-2+b1

Versions of packages clang-3.6 recommends:
ii  llvm-3.6-dev  1:3.6.2~+rc1-1~exp1
ii  python        2.7.9-1

Versions of packages clang-3.6 suggests:
pn  clang-3.6-doc  <none>
pn  gnustep        <none>
pn  gnustep-devel  <none>

-- no debconf information



More information about the Pkg-llvm-team mailing list