llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.84k forks source link

clang frontend segfaulted. Parser at end of file Optimzer #46199

Closed llvmbot closed 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 46855
Resolution WORKSFORME
Resolved on Jul 27, 2020 22:26
Version 9.0
OS Linux
Attachments line64-8b4776.c, line64-8b4776.sh (produced by clang)
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@fhahn,@zygoloid

Extended Description

While I was trying to build thunderbird mailer locally (specifically ASAN version), I got the following error.

clang-9: error: unable to execute command: Segmentation fault clang-9: error: clang frontend command failed due to signal (use -v to see invocation) clang version 9.0.1 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/ishikawa/.mozbuild/clang/bin clang-9: 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-9: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-9: note: diagnostic msg: /COMM-CENTRAL/TMP-DIR/line64-8b4776.c clang-9: note: diagnostic msg: /COMM-CENTRAL/TMP-DIR/line64-8b4776.sh clang-9: note: diagnostic msg:


So I am attaching the C source file and the accompanying .sh file.

llvmbot commented 4 years ago

I cannot reproduce the crash with latest trunk/LLVM 11.0 release branch.

Could you check if it is fixed in a newer version of clang, as I am not sure if there will be another Clang 9 bug fix update.

Thank for your analysis of successful compilation using clang-11.

I am using Debian GNU/Linux and I have downloaded clang-10 available from the Debian package repository. (clang-11 is not available yet, it seems.)

Will report back if it is fixed in clang 10.

clang-10 does not encounter this segfault(!).

Thank you!

llvmbot commented 4 years ago

I cannot reproduce the crash with latest trunk/LLVM 11.0 release branch.

Could you check if it is fixed in a newer version of clang, as I am not sure if there will be another Clang 9 bug fix update.

Thank for your analysis of successful compilation using clang-11.

I am using Debian GNU/Linux and I have downloaded clang-10 available from the Debian package repository. (clang-11 is not available yet, it seems.)

Will report back if it is fixed in clang 10.

fhahn commented 4 years ago

I cannot reproduce the crash with latest trunk/LLVM 11.0 release branch.

Could you check if it is fixed in a newer version of clang, as I am not sure if there will be another Clang 9 bug fix update.

llvmbot commented 4 years ago

Here is the complete stacktrace.

Stack dump:

  1. Program arguments: /home/ishikawa/.mozbuild/clang/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name line64.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=line-tables-only -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/comm/ldap/c-sdk/libraries/libldif/line64.gcno -resource-dir /home/ishikawa/.mozbuild/clang/lib/clang/9.0.1 -dependency-file .deps/line64.o.pp -MT line64.o -sys-header-deps -MP -include /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/mozilla-config.h -U _FORTIFY_SOURCE -D DEBUG=1 -D LINUX=1 -D LINUX2_0 -D linux=1 -D _PR_PTHREADS -D NET_SSL -D NS_DOMESTIC -D LDAP_DEBUG -D USE_WAITPID -D NEEDPROTOS -I /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/ldap/c-sdk/libraries/libldif -I /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/comm/ldap/c-sdk/libraries/libldif -I /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/ldap/c-sdk/include -I /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/dist/include -I /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/dist/include/nspr -I /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/dist/include/nss -D MOZILLA_CLIENT -D fdatasync=fdatasync -D DEBUG_4GB_CHECK -D USEHELGRIND=1 -D DEBUG=1 -internal-isystem /usr/local/include -internal-isystem /home/ishikawa/.mozbuild/clang/lib/clang/9.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Werror=sign-compare -Werror=unused-result -Werror=unused-variable -Werror=format -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wclass-varargs -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Werror=implicit-function-declaration -std=gnu99 -fdebug-compilation-dir /NEW-SSD/ASAN-OBJ-DIR/objdir-tb3/comm/ldap/c-sdk/libraries/libldif -ferror-limit 19 -fmessage-length 0 -fsanitize=address -fsanitize-blacklist=/home/ishikawa/.mozbuild/clang/lib/clang/9.0.1/share/asan_blacklist.txt -fsanitize-address-use-after-scope -fno-assume-sane-operator-new -pthread -ftrivial-auto-var-init=pattern -fno-builtin-strlen -fexperimental-new-pass-manager -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o line64.o -x c /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/ldap/c-sdk/libraries/libldif/line64.c
  2. parser at end of file
  3. Optimizer

    ​0 0x00007f1cfd4273cf llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x6453cf)

    ​1 0x00007f1cfd427707 SignalHandler(int) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x645707)

    ​2 0x00007f1cfcdb9110 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)

    ​3 0x00007f1cfe08e10a llvm::GetElementPtrInst::Create(llvm::Type, llvm::Value, llvm::ArrayRef<llvm::Value>, llvm::Twine const&, llvm::Instruction) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x12ac10a)

    ​4 0x00007f1cfe6116f4 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateGEP(llvm::Type, llvm::Value, llvm::Value*, llvm::Twine const&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x182f6f4)

    ​5 0x00007f1cfe7cb9fc llvm::LibCallSimplifier::optimizeStrChr(llvm::CallInst*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x19e99fc)

    ​6 0x00007f1cfe7cf402 llvm::LibCallSimplifier::optimizeStringMemoryLibCall(llvm::CallInst*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x19ed402)

    ​7 0x00007f1cfe30be3b llvm::LibCallSimplifier::optimizeCall(llvm::CallInst*) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x1529e3b)

    ​8 0x00007f1cfe3392a9 llvm::InstCombiner::visitCallBase(llvm::CallBase&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x15572a9)

    ​9 0x00007f1cfe32ee97 llvm::InstCombiner::visitCallInst(llvm::CallInst&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x154ce97)

    ​10 0x00007f1cfe31e24b llvm::InstCombiner::run() (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x153c24b)

    ​11 0x00007f1cfe31fbcc combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo, llvm::ProfileSummaryInfo, bool, llvm::LoopInfo) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x153dbcc)

    ​12 0x00007f1cfd8a64f8 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0xac44f8)

    ​13 0x00007f1cfdfb935d llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager >::run(llvm::Function&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x11d735d)

    ​14 0x00007f1cfd4d0cd7 llvm::PassManager<llvm::Function, llvm::AnalysisManager >::run(llvm::Function&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x6eecd7)

    ​15 0x00007f1cfdfc4cc0 llvm::ModuleToFunctionPassAdaptor<llvm::PassManager<llvm::Function, llvm::AnalysisManager > >::run(llvm::Module&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x11e2cc0)

    ​16 0x00007f1cfdfc4b9d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor<llvm::PassManager<llvm::Function, llvm::AnalysisManager > >, llvm::PreservedAnalyses, llvm::AnalysisManager >::run(llvm::Module&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x11e2b9d)

    ​17 0x00007f1cfd4cf91b llvm::PassManager<llvm::Module, llvm::AnalysisManager >::run(llvm::Module&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x6ed91b)

    ​18 0x00007f1cfdfd147d llvm::detail::PassModel<llvm::Module, llvm::PassManager<llvm::Module, llvm::AnalysisManager >, llvm::PreservedAnalyses, llvm::AnalysisManager >::run(llvm::Module&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x11ef47d)

    ​19 0x00007f1cfd4cf91b llvm::PassManager<llvm::Module, llvm::AnalysisManager >::run(llvm::Module&, llvm::AnalysisManager&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libLLVM-9.so+0x6ed91b)

    ​20 0x00007f1cfb57e9c9 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete >) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0xca69c9)

    ​21 0x00007f1cfc32d309 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 >) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1a55309)

    ​22 0x00007f1cfc64105f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1d6905f)

    ​23 0x00007f1cfc3dba68 clang::ParseAST(clang::Sema&, bool, bool) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1b03a68)

    ​24 0x00007f1cfc7463dd clang::FrontendAction::Execute() (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1e6e3dd)

    ​25 0x00007f1cfc703971 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1e2b971)

    ​26 0x00007f1cfc75955c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/ishikawa/.mozbuild/clang/bin/../lib/libclang-cpp.so.9+0x1e8155c)

    ​27 0x000000000041be40 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/home/ishikawa/.mozbuild/clang/bin/clang-9+0x41be40)

    ​28 0x00000000004186f0 main (/home/ishikawa/.mozbuild/clang/bin/clang-9+0x4186f0)

    ​29 0x00007f1cfa450e0b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26e0b)

    ​30 0x00000000004177f8 _start (/home/ishikawa/.mozbuild/clang/bin/clang-9+0x4177f8)

    clang-9: error: unable to execute command: Segmentation fault clang-9: error: clang frontend command failed due to signal (use -v to see invocation) clang version 9.0.1 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/ishikawa/.mozbuild/clang/bin clang-9: 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-9: note: diagnostic msg:


    PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-9: note: diagnostic msg: /COMM-CENTRAL/TMP-DIR/line64-8b4776.c clang-9: note: diagnostic msg: /COMM-CENTRAL/TMP-DIR/line64-8b4776.sh clang-9: note: diagnostic msg: