MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.78k stars 260 forks source link

Data race detected in do_initialize/getDriverMode/RegisterStatistic #963

Open theidexisted opened 6 months ago

theidexisted commented 6 months ago

Here are some things you should try before filing a bug report:


Observed behavior

Describe what happened. Any aids you can include (that you think could be relevant) are a tremendous help.

Data race detected by GTS

image

17:35:34 ccls           initialize.cc:276 I initialize in directory /home/xxxxx/dev/open-source/utils/ccls with uri file:///home/xxxxx/dev/open-source/utils/ccls/.
==================
WARNING: ThreadSanitizer: data race (pid=1175968)
  Write of size 8 at 0x5555559d95d8 by main thread:
    #0 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:280 (ccls+0x29ada9)
    #1 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #2 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #3 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

  Previous read of size 8 at 0x5555559d95d8 by thread T1:
    #0 preambleMain /home/xxxxx/dev/open-source/utils/ccls/src/sema_manager.cc:459 (ccls+0x1b2f3b)

  Location is global 'ccls::g_config' of size 8 at 0x5555559d95d8 (ccls+0x0000004855d8)

  Thread T1 'preamble' (tid=1175970, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 ccls::SemaManager::SemaManager(ccls::Project*, ccls::WorkingFiles*, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<ccls::Diagnostic, std::allocator<ccls::Diagnostic> >)>, std::function<void (ccls::RequestId)>) /home/xxxxx/dev/open-source/utils/ccls/src/sema_manager.cc:763 (ccls+0x1b6118)
    #3 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:771 (ccls+0x10c400)
    #4 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

SUMMARY: ThreadSanitizer: data race /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:280 in do_initialize
==================
17:35:35 ccls           initialize.cc:299 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"","cache":{"directory":".ccls-cache","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":[],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":true},"codeLens":{"localVariables":true},"completion":{"caseSensitivity":2,"detailedLabel":true,"dropOldRequests":true,"duplicateOptional":true,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":30,"suffixWhitelist":[".h",".hpp",".hh",".inc"],"whitelist":[]},"maxNum":100,"placeholder":true},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"lsRanges":false,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":5,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
17:35:35 ccls           initialize.cc:331 I use -resource-dir=/usr/lib/llvm-14/lib/clang/14.0.0
17:35:35 ccls           initialize.cc:363 I workspace folder: /home/xxxxx/dev/open-source/utils/ccls/
17:35:35 ccls              project.cc:429 I loaded /home/xxxxx/dev/open-source/utils/ccls/compile_commands.json
17:35:35 ccls           initialize.cc:388 I start 16 indexers
17:35:35 ccls           initialize.cc:396 I dispatch initial index requests
17:35:35 indexer13        pipeline.cc:386 I parse /home/xxxxx/dev/open-source/utils/ccls/src/platform_win.cc
17:35:35 indexer13        pipeline.cc:397 I store index for /home/xxxxx/dev/open-source/utils/ccls/src/platform_win.cc (delta: 0)
==================
WARNING: ThreadSanitizer: data race (pid=1175968)
  Read of size 8 at 0x7ffff73d7d10 by thread T5:
    #0 bcmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:905 (libtsan.so.0+0x686eb)
    #1 bcmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:901 (libtsan.so.0+0x686eb)
    #2 clang::driver::getDriverMode(llvm::StringRef, llvm::ArrayRef<char const*>) <null> (libclang-cpp.so.14+0x20c411f)
    #3 ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, bool, bool&) /home/xxxxx/dev/open-source/utils/ccls/src/indexer.cc:1318 (ccls+0x68af4)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Previous write of size 1 at 0x7ffff73d7d10 by thread T4:
    #0 memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827 (libtsan.so.0+0x6243e)
    #1 memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:819 (libtsan.so.0+0x6243e)
    #2 <null> <null> (libclang-cpp.so.14+0x20b9496)
    #3 ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, bool, bool&) /home/xxxxx/dev/open-source/utils/ccls/src/indexer.cc:1318 (ccls+0x68af4)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Location is global '<null>' at 0x000000000000 (libclang-cpp.so.14+0x0000037d7d10)

  Thread T5 'indexer1' (tid=1175974, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

  Thread T4 'indexer0' (tid=1175973, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

SUMMARY: ThreadSanitizer: data race (/usr/lib/llvm-14/lib/libclang-cpp.so.14+0x20c411f) in clang::driver::getDriverMode(llvm::StringRef, llvm::ArrayRef<char const*>)
==================
==================
WARNING: ThreadSanitizer: data race (pid=1175968)
  Atomic read of size 1 at 0x7b0c0001fd40 by thread T12:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
    #1 llvm::TrackingStatistic::RegisterStatistic() <null> (libLLVM-14.so.1+0xdd6b96)
    #2 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Previous write of size 8 at 0x7b0c0001fd40 by thread T11 (mutexes: write M10):
    #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162)
    #1 <null> <null> (libLLVM-14.so.1+0xdb8dea)
    #2 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Location is heap block of size 48 at 0x7b0c0001fd40 allocated by thread T11:
    #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162)
    #1 <null> <null> (libLLVM-14.so.1+0xdb8dea)
    #2 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Mutex M10 (0x7ffff3a50090) created at:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
    #1 llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const <null> (libLLVM-14.so.1+0xdb23d2)

  Thread T12 'indexer8' (tid=1175981, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

  Thread T11 'indexer7' (tid=1175980, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

SUMMARY: ThreadSanitizer: data race (/usr/lib/llvm-14/lib/libLLVM-14.so.1+0xdd6b96) in llvm::TrackingStatistic::RegisterStatistic()
==================
==================
WARNING: ThreadSanitizer: data race (pid=1175968)
  Read of size 8 at 0x7b080001b5e8 by thread T19:
    #0 bcmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:905 (libtsan.so.0+0x686eb)
    #1 bcmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:901 (libtsan.so.0+0x686eb)
    #2 llvm::StringMapImpl::FindKey(llvm::StringRef) const <null> (libLLVM-14.so.1+0xdda6b6)
    #3 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #5 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #6 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #7 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Previous write of size 8 at 0x7b080001b5e8 by thread T9:
    #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162)
    #1 <null> <null> (libclang-cpp.so.14+0x94f9d9)
    #2 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Location is heap block of size 26 at 0x7b080001b5e0 allocated by thread T9:
    #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162)
    #1 <null> <null> (libclang-cpp.so.14+0x94f9d9)
    #2 callback_fn<ccls::idx::index(ccls::SemaManager*, ccls::WorkingFiles*, ccls::VFS*, const string&, const string&, const std::vector<char const*>&, const std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >&, bool, bool&)::<lambda()> > /usr/include/llvm-14/llvm/ADT/STLFunctionalExtras.h:45 (ccls+0x6e531)
    #3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) <null> (libLLVM-14.so.1+0xd6bb6c)
    #4 indexer_Parse /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:358 (ccls+0x107efd)
    #5 ccls::pipeline::indexer_Main(ccls::SemaManager*, ccls::VFS*, ccls::Project*, ccls::WorkingFiles*) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:486 (ccls+0x109b01)
    #6 indexer /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:267 (ccls+0x29a259)

  Thread T19 'indexer15' (tid=1175988, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

  Thread T9 'indexer5' (tid=1175978, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8)
    #1 ccls::spawnThread(void* (*)(void*), void*) /home/xxxxx/dev/open-source/utils/ccls/src/platform_posix.cc:75 (ccls+0x15874d)
    #2 do_initialize /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:390 (ccls+0x29c095)
    #3 ccls::standaloneInitialize(ccls::MessageHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/messages/initialize.cc:427 (ccls+0x29cec8)
    #4 ccls::pipeline::standalone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/xxxxx/dev/open-source/utils/ccls/src/pipeline.cc:781 (ccls+0x10c500)
    #5 main /home/xxxxx/dev/open-source/utils/ccls/src/main.cc:137 (ccls+0x3767c)

SUMMARY: ThreadSanitizer: data race (/usr/lib/llvm-14/lib/libLLVM-14.so.1+0xdda6b6) in llvm::StringMapImpl::FindKey(llvm::StringRef) const
==================

Expected behavior

No data race

Steps to reproduce

  1. Build with -fsanitize=thread
  2. Run with ccls code base itself ccls -index=.

System information