vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

language server always crash while parsing chromium

Open AlanKing95 opened this issue 1 year ago • 4 comments

Environment

  • OS and Version: Linux PC 5.19.0-41-generic #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • VS Code Version: 1.83.1
  • C/C++ Extension Version: 1.18.5
  • If using SSH remote, specify OS of remote machine: my docker which is ubuntu 20.04

Bug Summary and Steps to Reproduce

Bug Summary: while parsing some simple projects, c_cpp works well while parsing chromium, the language server always crash

Steps to reproduce:

  1. download chromium and compile chromium
  2. run "./tools/clang/scripts/generate_compdb.py -p out_x86/default > out_x86/default/compile_commands.json" to generate compile_commands.json
  3. configure the project and start code analysis
  4. See error

Expected behavior:

Configuration and Logs

here is my configuration:

    "C_Cpp.autoAddFileAssociations": false,
    "C_Cpp.default.compileCommands": "${workspaceFolder:src}/out_x86/default/compile_commands.json",
    "C_Cpp.intelliSenseEngine": "default",
    "C_Cpp.intelliSenseCachePath": "${workspaceFolder:src}",
    "C_Cpp.formatting": "disabled",
    "C_Cpp.loggingLevel": "Debug",
    // "C_Cpp.errorSquiggles": "disabled",
    //"C_Cpp.workspaceParsingPriority": "low",

here are some logs while crash happens:

Attempting to get defaults from C++ compiler in compile_commands.json file: '/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++'
Compiler query command line: /home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wno-deprecated-non-prototype -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -fprofile-use=../../chrome/build/pgo_profiles/chrome-linux-5005-1653490340-736db1732ea5f3959ee14f875a1211fdb84a54af.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin -fsanitize=cfi-vcall -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wconversion -Wno-float-conversion -Wno-sign-conversion -Wno-implicit-float-conversion -Wno-implicit-int-conversion -Wno-shadow -std=c++17 -Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -Wno-deprecated-declarations -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
Attempting to get defaults from C++ compiler in compile_commands.json file: '/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++'
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.18.5
cpptools version (native): 1.18.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
Querying compiler for default C++ language standard using command line: /usr/bin/clang -x c++ -E -dM /dev/null
Detected language standard version: c++14
Querying compiler's default target using command line: "/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-pc-linux-gnu
Compiler query command line: /usr/bin/clang -std=c17 -m64 -Wp,-v -fno-blocks -E -dM -x c /dev/null
Attempting to get defaults from C compiler in "compilerPath" property: '/usr/bin/clang'
Compiler query command line: /usr/bin/clang -std=c++14 -m64 -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
Attempting to get defaults from C++ compiler in "compilerPath" property: '/usr/bin/clang'
LSP: (received) cpptools/didChangeCppProperties (id: 3)
LSP: (invoked) cpptools/didChangeCppProperties (id: 3)
LSP: (received - deferred) textDocument/didOpen: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc
LSP: (received - deferred) cpptools/activeDocumentChange: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc
LSP: (received - deferred) cpptools/getDocumentSymbols: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc (id: 4)
LSP: (received - deferred) cpptools/getInlayHints: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc (id: 5)
LSP: (received - deferred) cpptools/activeDocumentChange: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc
LSP: (received - deferred) cpptools/textEditorSelectionChange
LSP: (received - deferred) cpptools/resumeParsing
LSP: (received - deferred) cpptools/getFoldingRanges: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc (id: 6)
LSP: (received - deferred) cpptools/getSemanticTokens: file:///home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/ui/gl/gl_context_egl.cc (id: 7)
Code browsing service initialized
Attempting to get defaults from compiler found on the machine: '/usr/bin/clang'
Attempting to get defaults from compiler found on the machine: '/usr/bin/clang'
Querying compiler for default C++ language standard using command line: /home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++ -x c++ -E -dM /dev/null
Detected language standard version: c++14
Querying compiler's default target using command line: "/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++" -dumpmachine
Compiler returned default target value: x86_64-unknown-linux-gnu


by the way,i modify the compile_commands.json because the following errors will occur with the default compile_commands.json generate by chromium

Attempting to get defaults from C++ compiler in compile_commands.json file: '/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++'
Compiler query command line: /home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wno-deprecated-non-prototype -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -fno-omit-frame-pointer -g0 -fprofile-use=../../chrome/build/pgo_profiles/chrome-linux-5005-1653490340-736db1732ea5f3959ee14f875a1211fdb84a54af.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin -fsanitize=cfi-vcall -fsanitize-ignorelist=../../tools/cfi/ignores.txt -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wmissing-field-initializers -Wno-shadow -Wunreachable-code -Wshorten-64-to-32 -O3 -fdata-sections -ffunction-sections -fno-unique-section-names -Wno-string-concatenation -std=c++17 -Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -Wp,-v -fno-blocks -E -dM -x c++ /dev/null
clang++: [0;1;31merror: [0m[1mno such file or directory: '../../tools/cfi/ignores.txt'[0m

i remove all the compile flags with '../../tools/cfi/ignores.txt'

Other Extensions

No response

Additional context

No response

AlanKing95 avatar Nov 23 '23 07:11 AlanKing95

by the way,i modify the compile_commands.json because the following errors will occur with the default compile_commands.json generate by chromium

Attempting to get defaults from C++ compiler in compile_commands.json file: '/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++' Compiler query command line: /home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wno-deprecated-non-prototype -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -fno-omit-frame-pointer -g0 -fprofile-use=../../chrome/build/pgo_profiles/chrome-linux-5005-1653490340-736db1732ea5f3959ee14f875a1211fdb84a54af.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin -fsanitize=cfi-vcall -fsanitize-ignorelist=../../tools/cfi/ignores.txt -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wmissing-field-initializers -Wno-shadow -Wunreachable-code -Wshorten-64-to-32 -O3 -fdata-sections -ffunction-sections -fno-unique-section-names -Wno-string-concatenation -std=c++17 -Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -Wp,-v -fno-blocks -E -dM -x c++ /dev/null clang++: �[0;1;31merror: �[0m�[1mno such file or directory: '../../tools/cfi/ignores.txt'�[0m

i remove all the compile flags with '../../tools/cfi/ignores.txt'

this is also an issue, because the file exist

here is a file in the default compile_commands.json { "directory": "/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default", "command": "ccache ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/base/base/allocator_check.o.d -DUSE_SYMBOLIZE -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -DOFFICIAL_BUILD -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -DCR_CLANG_REVISION=\"llvmorg-15-init-7570-gba4537b2-1\" -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_DEBUG=0 -DCR_LIBCXX_REVISION=79a2e924d96e2fc1e4b937c42efd08898fa472d7 -DCR_SYSROOT_HASH=60354520bb7001d8d0288a2ab82cec7efec9fa3d -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -Wall -Werror -Wextra -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wno-deprecated-non-prototype -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -g0 -fprofile-use=../../chrome/build/pgo_profiles/chrome-linux-5005-1653490340-736db1732ea5f3959ee14f875a1211fdb84a54af.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin -fsanitize=cfi-vcall -fsanitize-ignorelist=../../tools/cfi/ignores.txt -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wexit-time-destructors -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -DPROTOBUF_ALLOW_DEPRECATED=1 -std=c++17 -Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../base/allocator/allocator_check.cc -o obj/base/base/allocator_check.o", "file": "../../base/allocator/allocator_check.cc" },

the "../../tools/cfi/ignores.txt" can be find in "/home/jinbiao/work/google_chromium-102.0.5005.200/chromium/src/out_x86/default/../../tools/cfi/ignores.txt"

AlanKing95 avatar Nov 23 '23 07:11 AlanKing95

hi @sean-mcmanus, will it be fixed in the comimng version?

AlanKing95 avatar Dec 07 '23 04:12 AlanKing95

@AlanKing95 I don't think it'll be fixed for 1.19.2, but we'll try to look into it after that.

sean-mcmanus avatar Jan 17 '24 00:01 sean-mcmanus

I believe I've addressed the crash and several issues with clang-cl querying in 1.19.3 (which should be available very soon). It looks like there is still an issue parsing something in the codebase, preventing good IntellISense results. Once 1.19.3 is out, we might set to this help wanted, to try to uncover the specific code that is leading to the IntellISense issue.

Colengms avatar Feb 01 '24 22:02 Colengms