ccls: segmentation fault (core dumped)

a couple hours ago, ccls was just fine. I tested some basic features under spacemacs.

However, two hours ago, after I recompiled aur/ccls-git and updated lsp-mode, ccls package in emacs, errors occurred!

coredump info:

$ coredumpctl info 22625
           PID: 22625 (ccls)
           PID: 22625 (ccls)
           UID: 1000 (shaikh)
           GID: 1000 (shaikh)
        Signal: 11 (SEGV)
     Timestamp: Mon 2018-07-09 17:02:15 CST (19s ago)
  Command Line: /usr/bin/ccls --log-file=/tmp/ccls.log
    Executable: /usr/bin/ccls
 Control Group: /user.slice/user-1000.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1000.slice
       Session: c1
     Owner UID: 1000 (shaikh)
       Boot ID: efe30e1d1af340cdb19ae8455ccd625d
    Machine ID: 26f090b164cf43619ddb4a3c9c38ae60
      Hostname: ArchX
       Storage: /var/lib/systemd/coredump/core.ccls.1000.efe30e1d1af340cdb19ae8455ccd625d.22625.1531126935000000.lz4
       Message: Process 22625 (ccls) of user 1000 dumped core.
                
                Stack trace of thread 22633:
                #0  0x00007efe317f9d08 _ZN4llvm3sys2fs6detail28directory_iterator_constructERNS2_12DirIterStateENS_9StringRefEb (libLLVM-7svn.so)
                #1  0x0000560f164d3bd8 n/a (ccls)
                #2  0x0000560f163c39f1 n/a (ccls)
                #3  0x0000560f163c4a3b n/a (ccls)
                #4  0x0000560f163d81a5 n/a (ccls)
                #5  0x0000560f1633495b _ZNK5clang6driver6Driver12getToolChainERKN4llvm3opt7ArgListERKNS2_6TripleE (ccls)
                #6  0x0000560f16340343 _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #7  0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEngineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #8  0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB_I12FileContentsSaISG_EE (ccls)
                #9  0x0000560f156679b1 n/a (ccls)
                #10 0x0000560f15668adc _ZN4ccls8pipeline12Indexer_MainEP20DiagnosticsPublisherP3VFSP7ProjectP12WorkingFiles (ccls)
                #11 0x0000560f156d352d n/a (ccls)
                #12 0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #13 0x00007efe30772075 start_thread (libpthread.so.0)
                #14 0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22625:
                #0  0x00007efe30777ffc pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0)
                #1  0x00007efe30c55d6d __gthread_cond_wait (libstdc++.so.6)
                #2  0x0000560f15669cf2 _ZN4ccls8pipeline8MainLoopEv (ccls)
                #3  0x0000560f155feebc main (ccls)
                #4  0x00007efe303d206b __libc_start_main (libc.so.6)
                #5  0x0000560f1560365a _start (ccls)
                
                Stack trace of thread 22632:
                #0  0x00007efe317f9d08 _ZN4llvm3sys2fs6detail28directory_iterator_constructERNS2_12DirIterStateENS_9StringRefEb (libLLVM-7svn.so)
                #1  0x0000560f164d3bd8 n/a (ccls)
                #2  0x0000560f163c39f1 n/a (ccls)
                #3  0x0000560f163c4a3b n/a (ccls)
                #4  0x0000560f163d81a5 n/a (ccls)
                #5  0x0000560f1633495b _ZNK5clang6driver6Driver12getToolChainERKN4llvm3opt7ArgListERKNS2_6TripleE (ccls)
                #6  0x0000560f16340343 _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #7  0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEngineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #8  0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB_I12FileContentsSaISG_EE (ccls)
                #9  0x0000560f156679b1 n/a (ccls)
                #10 0x0000560f15668adc _ZN4ccls8pipeline12Indexer_MainEP20DiagnosticsPublisherP3VFSP7ProjectP12WorkingFiles (ccls)
                #11 0x0000560f156d352d n/a (ccls)
                #12 0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #13 0x00007efe30772075 start_thread (libpthread.so.0)
                #14 0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22627:
                #0  0x00007efe30777ffc pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0)
                #1  0x00007efe30c55d6d __gthread_cond_wait (libstdc++.so.6)
                #2  0x0000560f1566478b n/a (ccls)
                #3  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #4  0x00007efe30772075 start_thread (libpthread.so.0)
                #5  0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22634:
                #0  0x00007efe3077cb50 __libc_sigaction (libpthread.so.0)
                #1  0x00007efe31804af1 _ZL13SignalHandleri (libLLVM-7svn.so)
                #2  0x00007efe3077ca80 __restore_rt (libpthread.so.0)
                #3  0x00007efe317f9d08 _ZN4llvm3sys2fs6detail28directory_iterator_constructERNS2_12DirIterStateENS_9StringRefEb (libLLVM-7svn.so)
                #4  0x0000560f164d3bd8 n/a (ccls)
                #5  0x0000560f163c39f1 n/a (ccls)
                #6  0x0000560f163c4a3b n/a (ccls)
                #7  0x0000560f163d81a5 n/a (ccls)
                #8  0x0000560f1633495b _ZNK5clang6driver6Driver12getToolChainERKN4llvm3opt7ArgListERKNS2_6TripleE (ccls)
                #9  0x0000560f16340343 _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #10 0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEngineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #11 0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB_I12FileContentsSaISG_EE (ccls)
                #12 0x0000560f156679b1 n/a (ccls)
                #13 0x0000560f15668adc _ZN4ccls8pipeline12Indexer_MainEP20DiagnosticsPublisherP3VFSP7ProjectP12WorkingFiles (ccls)
                #14 0x0000560f156d352d n/a (ccls)
                #15 0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #16 0x00007efe30772075 start_thread (libpthread.so.0)
                #17 0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22628:
                #0  0x00007efe30777ffc pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0)
                #1  0x00007efe30c55d6d __gthread_cond_wait (libstdc++.so.6)
                #2  0x0000560f1560ed51 _ZNSt3_V222condition_variable_any4waitISt11unique_lockISt5mutexEEEvRT_ (ccls)
                #3  0x0000560f1560f09b _ZN13ThreadedQueueISt10unique_ptrIN20ClangCompleteManager17CompletionRequestESt14default_deleteIS2_EEE7DequeueEv (ccls)
                #4  0x0000560f1560a71b n/a (ccls)
                #5  0x0000560f1560b7bf n/a (ccls)
                #6  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #7  0x00007efe30772075 start_thread (libpthread.so.0)
                #8  0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22629:
                #0  0x00007efe30777ffc pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0)
                #1  0x00007efe30c55d6d __gthread_cond_wait (libstdc++.so.6)
                #2  0x0000560f1560ed51 _ZNSt3_V222condition_variable_any4waitISt11unique_lockISt5mutexEEEvRT_ (ccls)
                #3  0x0000560f15609960 n/a (ccls)
                #4  0x0000560f15609a6f n/a (ccls)
                #5  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #6  0x00007efe30772075 start_thread (libpthread.so.0)
                #7  0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22630:
                #0  0x00007efe30777ffc pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0)
                #1  0x00007efe30c55d6d __gthread_cond_wait (libstdc++.so.6)
                #2  0x0000560f1560ed51 _ZNSt3_V222condition_variable_any4waitISt11unique_lockISt5mutexEEEvRT_ (ccls)
                #3  0x0000560f1560a2d6 n/a (ccls)
                #4  0x0000560f1560a6bf n/a (ccls)
                #5  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #6  0x00007efe30772075 start_thread (libpthread.so.0)
                #7  0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22626:
                #0  0x00007efe30498934 __read (libc.so.6)
                #1  0x00007efe3042a788 _IO_file_underflow@@GLIBC_2.2.5 (libc.so.6)
                #2  0x00007efe3042b8a2 _IO_default_uflow (libc.so.6)
                #3  0x00007efe304261f0 _IO_getc (libc.so.6)
                #4  0x0000560f15638d5e _Z25ReadCharFromStdinBlockingv (ccls)
                #5  0x0000560f156393e7 _Z22ReadJsonRpcContentFromB5cxx11St8functionIFSt8optionalIcEvEE (ccls)
                #6  0x0000560f1563c30c _ZN15MessageRegistry20ReadMessageFromStdinB5cxx11EPSt10unique_ptrI9InMessageSt14default_deleteIS1_EE (ccls)
                #7  0x0000560f15665606 n/a (ccls)
                #8  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #9  0x00007efe30772075 start_thread (libpthread.so.0)
                #10 0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22631:
                #0  0x00007efe30509669 __strlen_avx2 (libc.so.6)
                #1  0x00007efe32a99b7c _ZNK4llvm3opt8OptTable11ParseOneArgERKNS0_7ArgListERjjj (libLLVM-7svn.so)
                #2  0x00007efe32a9a17e _ZNK4llvm3opt8OptTable9ParseArgsENS_8ArrayRefIPKcEERjS6_jj (libLLVM-7svn.so)
                #3  0x0000560f16326dbc _ZN5clang6driver6Driver15ParseArgStringsEN4llvm8ArrayRefIPKcEERb (ccls)
                #4  0x0000560f1633fc2b _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #5  0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEngineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #6  0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB_I12FileContentsSaISG_EE (ccls)
                #7  0x0000560f156679b1 n/a (ccls)
                #8  0x0000560f15668adc _ZN4ccls8pipeline12Indexer_MainEP20DiagnosticsPublisherP3VFSP7ProjectP12WorkingFiles (ccls)
                #9  0x0000560f156d352d n/a (ccls)
                #10 0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #11 0x00007efe30772075 start_thread (libpthread.so.0)
                #12 0x00007efe304a753f __clone (libc.so.6)

           PID: 22625 (ccls)
           UID: 1000 (shaikh)
           GID: 1000 (shaikh)
        Signal: 11 (SEGV)
     Timestamp: Mon 2018-07-09 17:02:15 CST (19s ago)
  Command Line: /usr/bin/ccls --log-file=/tmp/ccls.log
    Executable: /usr/bin/ccls
 Control Group: /user.slice/user-1000.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1000.slice
       Session: c1
     Owner UID: 1000 (shaikh)
       Boot ID: efe30e1d1af340cdb19ae8455ccd625d
    Machine ID: 26f090b164cf43619ddb4a3c9c38ae60
      Hostname: ArchX
       Storage: /var/lib/systemd/coredump/core.ccls.1000.efe30e1d1af340cdb19ae8455ccd625d.22625.1531126935000000.lz4
       Message: Process 22625 (ccls) of user 1000 dumped core.
                
                Stack trace of thread 22633:
                #0  0x00007efe317f9d08 _ZN4llvm3sys2fs6detail28directory_iterator_constructERNS2_12DirIterStateENS_9StringRefEb (libLLVM-7svn.so)
                #1  0x0000560f164d3bd8 n/a (ccls)
                #2  0x0000560f163c39f1 n/a (ccls)
                #3  0x0000560f163c4a3b n/a (ccls)
                #4  0x0000560f163d81a5 n/a (ccls)
                #5  0x0000560f1633495b _ZNK5clang6driver6Driver12getToolChainERKN4llvm3opt7ArgListERKNS2_6TripleE (ccls)
                #6  0x0000560f16340343 _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #7  0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEng
ineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #8  0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB
_I12FileContentsSaISG_EE (ccls)
                #9  0x0000560f156679b1 n/a (ccls)
...skipping...
                #7  0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22626:
                #0  0x00007efe30498934 __read (libc.so.6)
                #1  0x00007efe3042a788 _IO_file_underflow@@GLIBC_2.2.5 (libc.so.6)
                #2  0x00007efe3042b8a2 _IO_default_uflow (libc.so.6)
                #3  0x00007efe304261f0 _IO_getc (libc.so.6)
                #4  0x0000560f15638d5e _Z25ReadCharFromStdinBlockingv (ccls)
                #5  0x0000560f156393e7 _Z22ReadJsonRpcContentFromB5cxx11St8functionIFSt8optionalIcEvEE (ccls)
                #6  0x0000560f1563c30c _ZN15MessageRegistry20ReadMessageFromStdinB5cxx11EPSt10unique_ptrI9InMessageSt14default_deleteIS1_EE (ccls)
                #7  0x0000560f15665606 n/a (ccls)
                #8  0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #9  0x00007efe30772075 start_thread (libpthread.so.0)
                #10 0x00007efe304a753f __clone (libc.so.6)
                
                Stack trace of thread 22631:
                #0  0x00007efe30509669 __strlen_avx2 (libc.so.6)
                #1  0x00007efe32a99b7c _ZNK4llvm3opt8OptTable11ParseOneArgERKNS0_7ArgListERjjj (libLLVM-7svn.so)
                #2  0x00007efe32a9a17e _ZNK4llvm3opt8OptTable9ParseArgsENS_8ArrayRefIPKcEERjS6_jj (libLLVM-7svn.so)
                #3  0x0000560f16326dbc _ZN5clang6driver6Driver15ParseArgStringsEN4llvm8ArrayRefIPKcEERb (ccls)
                #4  0x0000560f1633fc2b _ZN5clang6driver6Driver16BuildCompilationEN4llvm8ArrayRefIPKcEE (ccls)
                #5  0x0000560f1578a207 _ZN5clang31createInvocationFromCommandLineEN4llvm8ArrayRefIPKcEENS0_18IntrusiveRefCntPtrINS_17DiagnosticsEngineEEENS5_INS_3vfs10FileSystemEEE (ccls)
                #6  0x0000560f1562d71c _ZN4ccls3idx5IndexEP3VFSRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_RKSt6vectorIS8_SaIS8_EERKSB_I12FileContentsSaISG_EE (ccls)
                #7  0x0000560f156679b1 n/a (ccls)
                #8  0x0000560f15668adc _ZN4ccls8pipeline12Indexer_MainEP20DiagnosticsPublisherP3VFSP7ProjectP12WorkingFiles (ccls)
                #9  0x0000560f156d352d n/a (ccls)
                #10 0x00007efe30c5bd4f execute_native_thread_routine (libstdc++.so.6)
                #11 0x00007efe30772075 start_thread (libpthread.so.0)
                #12 0x00007efe304a753f __clone (libc.so.6)

ccls-log:

$ cat /tmp/ccls.log             
17:02:15 ccls           initialize.cc:431 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"","cacheDirectory":"/home/shaikh/Documents/modern.c++/part1/chap2/.ccls-cache/","cacheFormat":"binary","clang":{"extraArgs":["-D__cpp_deduction_guides=0","-Wno-macro-redefined"],"resourceDir":""},"client":{"snippetSupport":false},"codeLens":{"localVariables":true},"completion":{"caseSensitivity":2,"dropOldRequests":true,"detailedLabel":false,"filterAndSort":true,"includeBlacklist":[],"includeMaxPathSize":30,"includeSuffixWhitelist":[".h",".hpp",".hh"],"includeWhitelist":[]},"diagnostics":{"blacklist":[],"frequencyMs":0,"onParse":true,"onType":true,"whitelist":[]},"highlight":{"blacklist":[],"whitelist":[]},"index":{"attributeMakeCallsToCtor":true,"blacklist":[],"comments":2,"enabled":true,"onDidChange":false,"reparseForDependency":2,"threads":0,"whitelist":[]},"largeFileSize":2097152,"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"container":false,"maxNum":2000}}
17:02:15 ccls           initialize.cc:435 I initialize in directory /home/shaikh/Documents/modern.c++/part1/chap2 with uri file:///home/shaikh/Documents/modern.c++/part1/chap2/
17:02:15 ccls           initialize.cc:472 I Using -resource-dir=/usr/lib/clang/7.0.0
17:02:15 ccls              project.cc:319 I loaded /home/shaikh/Documents/modern.c++/part1/chap2/compile_commands.json
17:02:15 ccls           initialize.cc:506 I start 4 indexers
17:02:15 ccls           initialize.cc:520 I dispatch initial index requests
17:02:15 indexer2         pipeline.cc:219 I parse /home/shaikh/Documents/modern.c++/part1/chap2/2.4-const.cpp
17:02:15 indexer3         pipeline.cc:219 I parse /home/shaikh/Documents/modern.c++/part1/chap2/2.1.2-type_conversions.cpp
17:02:15 indexer1         pipeline.cc:219 I parse /home/shaikh/Documents/modern.c++/part1/chap2/2.3.2-pointers.cpp
17:02:15 indexer0         pipeline.cc:219 I parse /home/shaikh/Documents/modern.c++/part1/chap2/2.3.3-compound_types.cpp
17:02:15 ccls         message_handler.cc:152 I "/home/shaikh/Documents/modern.c++/part1/chap2/2.4-const.cpp" is being indexed.

the test file 2.4-const.cpp has not been changed.

ccls package version

elpa/26.1/develop/ccls-20180708.1828

lsp-mode version

elpa/26.1/develop/lsp-mode-20180708.1914

maybe I could roll back the emacs packages. but I don’t know how to downgrade a aur/ccls-gt package. or should I build ccls by git and compiling the source code?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 35 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Since aur/ccls-git 1668.558516d-1, the SIGSEGV issue no longer exists.

Add -DLLVM_ENABLE_RTTI=on

The SIGSEGV issue has been identified. It was because extra/clang were
compiled with -DLLVM_ENABLE_RTTI=ON while aur/ccls-git used -fno-rtti.

The mismatch leaded /usr/include/c++/8/bits/shared_ptr_base.h
_M_get_deleter to return nullptr.
      // Sneaky trick so __shared_ptr can get the managed pointer
      virtual void*
      _M_get_deleter(const std::type_info& __ti) noexcept
      {
#if __cpp_rtti
	if (__ti == typeid(_Sp_make_shared_tag))
#else
	if (&__ti == &_Sp_make_shared_tag::_S_ti())
#endif
	  return const_cast<typename remove_cv<_Tp>::type*>(_M_ptr());
	return nullptr;
      }

I built and installed extra/clang and extra/llvm with options=('debug' '!strip'). IDA was woefully slow to analyze the 60+M libLLVM-6.0.so (original Arch Linux one, without debug info).

# rr session
58^@ 566       _M_get_deleter(const std::type_info& __ti) noexcept
59^@    0x000056482f1f2530 <+0>: lea    rax,[rip+0xf4e09]        # 0x56482f2e7340 <_ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag>
60^@    0x000056482f1f2537 <+7>: add    rdi,0x10
61^@    0x000056482f1f253b <+11>:  cmp    rsi,rax
62^@    0x000056482f1f253e <+14>:  mov    eax,0x0
63^@    0x000056482f1f2543 <+19>:  cmove  rax,rdi
64^@    0x000056482f1f2547 <+23>:  ret

(rr) i r rsi
rsi            0x7f2719ac15e8      139805911160296
(rr) i r rax
rax            0x56482f2e7340      94868029207360

(rr) info symbol 0x7f2719ac15e8
typeinfo for std::_Sp_make_shared_tag in section .data.rel.ro of /usr/lib/libclangTooling.so.6
(rr) info symbol 0x56482f2e7340
std::_Sp_make_shared_tag::_S_ti()::__tag in section .rodata of /usr/bin/ccls

Ironically, I have fixed an immediately related issue of using clang with libstdc++ 8 “Explicitly mark _S_ti() as default visibility to work around clang -fvisibility-inlines-hidden bug”. The patch should be available for the next release (GCC > 8.2)