microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.54k stars 1.56k forks source link

language server crash repeatedly probably because of the database file #12937

Open Mipsters opened 2 weeks ago

Mipsters commented 2 weeks ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: language server crashes

Steps to reproduce:

  1. it reproduces randomly while going through c/cpp files in the project

Expected behavior: language server doesn't crash

the issue is averted if following these instructions and changing the value of databaseFilename: https://github.com/microsoft/vscode-cpptools/issues/2296#issuecomment-406453073

Configuration and Logs

Debug logs: this lines repeats a lot, can't share more because of company policy

Unable to add file to database, error = 0x8064000b: ...

crash call stack:

browse_engine::query_translation_unit_source(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*) (Unknown Source:0)
intellisense_client_manager::find_existing_intellisense_client(msvc::locked_object<intellisense_client_manager::maps, std::recursive_mutex, std::unique_lock> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, bool&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, bool&, bool&) (Unknown Source:0)
intellisense_client_manager::acquire_intellisense_client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, acquire_intellisense_client_options const&, std::function<void (intellisense_client_reference&&)>&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::function<bool ()> const&)::{lambda()#2}::operator()() (Unknown Source:0)
msvc::thread_manager_t::do_work(unsigned int) (Unknown Source:0)
msvc::thread_helper_t::thread_entry(void*) (Unknown Source:0)
libc.so!start (Unknown Source:0)
libc.so!__clone (Unknown Source:0)
[Unknown/Just-In-Time compiled code] (Unknown Source:0)

partial content of ~/.vscode-server/data/Machine/settings.json some values redacted

{
    // ...
    "C_Cpp.default.compilerPath": "/usr/bin/gcc",
    "C_Cpp.default.cStandard": "gnu17",
    "C_Cpp.default.cppStandard": "gnu++17",
    "C_Cpp.default.defines": ["<PROJECT_SPECIFIC_DEFINE>"],
    "C_Cpp.default.includePath": [
        "${env:HOME}/<SOME_SDK_PATH>",
        "${env:HOME}/<SOME_SDK_PATH>/include",
        "${workspaceFolder}/**",
        "${workspaceFolder}/include",
        "${workspaceFolder}/src",
        // 40 lines of different folders under ${workspaceFolder}
    ],
    "C_Cpp.default.forcedInclude": [
        // 4 .h files from some includes under ${workspaceFolder}
    ],

Other Extensions

No response

Additional context

No response

sean-mcmanus commented 2 weeks ago

@Mipsters Are you opening the same workspace (with the same database) in multiple VS Code instances or is there a dangling cpptools process running (when VS Code has not loaded a workspace).

sean-mcmanus commented 2 weeks ago

@Mipsters Also, does it stop crashing after you run the C/C++: Reset IntelliSense Database command from the command palette? You should get a success notification if the reset was successful.

Mipsters commented 2 weeks ago

@sean-mcmanus

Are you opening the same workspace (with the same database) in multiple VS Code instances

Seldom, but it occurs also when there is only one instance

is there a dangling cpptools process running (when VS Code has not loaded a workspace

I don't think so, if you are talking about the cpptools process it doesn't seem like it

does it stop crashing after you run the C/C++: Reset IntelliSense Database command

Not sure, I'll try to reproduce it and check, but it may be a while

sean-mcmanus commented 2 weeks ago

@Mipsters Also, 1.23.0 has some crash fixes and 1.23.1 (pending release today) has more crash fixes, but we don't know yet if it fixes this particular crash.

sean-mcmanus commented 2 weeks ago

@Mipsters Also, I've seen Unable to add file to database, error = 0x8064000b: ... but I'm not certain if it causes a bug or if it's related to the crash. The crashing call stack acquire_intellisense_client is when you open a new file or something triggers an IntelliSense process to be started and query_translation_unit_source is querying the database to find which source file to use for a header, so it seems like your repro may require opening some header, maybe when the database is doing some other work (maybe scanning the workspace for files not in the database).