[cfe-dev] clang segmentation fault in versions >=5.0.2 with `-debug-info-kind=limited`

Kaveh Vaghefi via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 9 11:20:55 PDT 2018


We run clang in a docker container based on Ubuntu 16.04.  In it we download the tar.xz archive for clang, place it in /opt, and symlink it in using `update-alternatives` (here's the line from our Dockerfile)

RUN export CLANG_VERSION=5.0.1 && \
    export CLANG_PKG=clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-16.04 && \
    wget --progress=bar:force http://llvm.org/releases/$CLANG_VERSION/$CLANG_PKG.tar.xz && \
    tar xvfJ $CLANG_PKG.tar.xz -C /opt && \
    chmod -R 755 /opt/$CLANG_PKG && \
    # make symlinks to abstract compiler version
    update-alternatives --install /usr/bin/clang clang /opt/$CLANG_PKG/bin/clang 100 \
        --slave /usr/bin/clang++ clang++ /opt/$CLANG_PKG/bin/clang++ \
        --slave /usr/bin/llvm-symbolizer llvm-symbolizer /opt/$CLANG_PKG/bin/llvm-symbolizer \
        --slave /usr/bin/llvm-profdata llvm-profdata /opt/$CLANG_PKG/bin/llvm-profdata\
        --slave /usr/bin/llvm-ar llvm-ar /opt/$CLANG_PKG/bin/llvm-ar \
        --slave /usr/bin/lld lld /opt/$CLANG_PKG/bin/lld \
        --slave /usr/bin/llvm-nm llvm-nm /opt/$CLANG_PKG/bin/llvm-nm \
        --slave /usr/bin/llvm-objdump llvm-objdump /opt/$CLANG_PKG/bin/llvm-objdump \
        --slave /usr/bin/clang-format clang-format /opt/$CLANG_PKG/bin/clang-format \
        --slave /usr/bin/llvm-ranlib llvm-ranlib /opt/$CLANG_PKG/bin/llvm-ranlib \
        --slave /lib/libc++.so libc++.so /opt/$CLANG_PKG/lib/libc++.so \
        --slave /lib/libc++.so.1 libc++.so.1 /opt/$CLANG_PKG/lib/libc++.so.1 \
        --slave /lib/libc++.so.1.0 libc++.so.1.0 /opt/$CLANG_PKG/lib/libc++.so.1.0 \
        --slave /lib/libc++abi.so libc++abi.so /opt/$CLANG_PKG/lib/libc++abi.so \
        --slave /lib/libc++abi.so.1 libc++abi.so.1 /opt/$CLANG_PKG/lib/libc++abi.so.1 \
        --slave /lib/libc++abi.so.1.0 libc++abi.so.1.0 /opt/$CLANG_PKG/lib/libc++abi.so.1.0 \
        --slave /lib/libomp.so libomp.so /opt/$CLANG_PKG/lib/libomp.so

I'm finding that if I use any version after 5.0.1, clang exhibits a segmentation fault with the `-g` option passed in.  If I remove the `-debug-info-kind=limited` command on the invocation below, the segmentation fault does not happen.  I believe this is a bug that needs to be fixed, but I'd appreciate the insight of someone more knowledgable with clang.

$ /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0 \
> -cc1 \
> -triple x86_64-unknown-linux-gnu \
> -emit-obj \
> --compress-debug-sections \
> -disable-free \
> -disable-llvm-verifier \
> -discard-value-names \
> -main-file-name buildinfo_query.cc \
> -mrelocation-model static \
> -mthread-model posix \
> -mdisable-fp-elim \
> -fmath-errno \
> -masm-verbose \
> -mconstructor-aliases \
> -munwind-tables \
> -fuse-init-array \
> -target-cpu x86-64 \
> -momit-leaf-frame-pointer \
> -dwarf-column-info \
> -debug-info-kind=limited \
> -dwarf-version=4 \
> -debugger-tuning=gdb \
> -coverage-notes-file /proc/self/cwd/bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.gcno \
> -resource-dir /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/lib/clang/5.0.2 \
> -dependency-file bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.d \
> -MT bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.o \
> -sys-header-deps \
> -iquote . \
> -iquote bazel-out/k8-py3-opt/genfiles \
> -iquote external/bazel_tools \
> -iquote bazel-out/k8-py3-opt/genfiles/external/bazel_tools \
> -isystem external/bazel_tools/tools/cpp/gcc3 \
> -D NDEBUG \
> -internal-isystem /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/../include/c++/v1 \
> -internal-isystem /usr/local/include \
> -internal-isystem /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/lib/clang/5.0.2/include \
> -internal-externc-isystem /usr/include/x86_64-linux-gnu \
> -internal-externc-isystem /usr/include \
> -O3 \
> -Wthread-safety \
> -Wno-unknown-pragmas \
> -Wno-inconsistent-missing-override \
> -Wno-deprecated-register \
> -Werror \
> -Wno-sign-compare \
> -Wno-invalid-partial-specialization \
> -std=c++1z \
> -fdeprecated-macro \
> -fdebug-compilation-dir /proc/self/cwd \
> -ferror-limit 19 \
> -fmessage-length 0 \
> -fopenmp \
> -fobjc-runtime=gcc \
> -fcxx-exceptions \
> -fexceptions \
> -fdiagnostics-show-option \
> -vectorize-loops \
> -vectorize-slp \
> -o bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.o \
> -x c++ devtools/buildinfo_query.cc
#0 0x0000000001a63ae4 PrintStackTraceSignalHandler(void*) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1a63ae4)
#1 0x0000000001a63dc6 SignalHandler(int) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1a63dc6)
#2 0x00007fa3729bd390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#3 0x000000000181e2a4 llvm::Error llvm::handleErrors<llvm::consumeError(llvm::Error)::{lambda(llvm::ErrorInfoBase const&)#1}>(llvm::Error, llvm::consumeError(llvm::Error)::{lambda(llvm::ErrorInfoBase const&)#1}&&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x181e2a4)
#4 0x0000000001819b37 (anonymous namespace)::ELFObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1819b37)
#5 0x000000000182a8bb llvm::MCAssembler::Finish() (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x182a8bb)
#6 0x000000000207ef9c llvm::AsmPrinter::doFinalization(llvm::Module&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x207ef9c)
#7 0x000000000169b163 llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x169b163)
#8 0x000000000169b561 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x169b561)
#9 0x0000000001ba4dd2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1ba4dd2)
#10 0x0000000002298f0d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x2298f0d)
#11 0x00000000024c5636 clang::ParseAST(clang::Sema&, bool, bool) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x24c5636)
#12 0x0000000001f2cf0f clang::FrontendAction::Execute() (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1f2cf0f)
#13 0x0000000001ede2b8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1ede2b8)
#14 0x0000000001fa94ad clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x1fa94ad)
#15 0x00000000008afd51 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x8afd51)
#16 0x00000000008ae5e6 main (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x8ae5e6)
#17 0x00007fa371955830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#18 0x00000000008ab999 _start (/opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0+0x8ab999)
Stack dump:
0.	Program arguments: /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --compress-debug-sections -disable-free -disable-llvm-verifier -discard-value-names -main-file-name buildinfo_query.cc -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /proc/self/cwd/bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.gcno -resource-dir /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/lib/clang/5.0.2 -dependency-file bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.d -MT bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.o -sys-header-deps -iquote . -iquote bazel-out/k8-py3-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/k8-py3-opt/genfiles/external/bazel_tools -isystem external/bazel_tools/tools/cpp/gcc3 -D NDEBUG -internal-isystem /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /opt/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/lib/clang/5.0.2/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include -O3 -Wthread-safety -Wno-unknown-pragmas -Wno-inconsistent-missing-override -Wno-deprecated-register -Werror -Wno-sign-compare -Wno-invalid-partial-specialization -std=c++1z -fdeprecated-macro -fdebug-compilation-dir /proc/self/cwd -ferror-limit 19 -fmessage-length 0 -fopenmp -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o bazel-out/k8-py3-opt/bin/devtools/_objs/buildinfo_query/devtools/buildinfo_query.o -x c++ devtools/buildinfo_query.cc
1.	<eof> parser at end of file
2.	Code generation
Segmentation fault (core dumped)





More information about the cfe-dev mailing list