Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliSense crashing when hovering over certain C++ types of data. #11510

Closed
conkerkh opened this issue Oct 6, 2023 · 8 comments
Closed

IntelliSense crashing when hovering over certain C++ types of data. #11510

conkerkh opened this issue Oct 6, 2023 · 8 comments
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix Visual Studio Inherited from Visual Studio
Milestone

Comments

@conkerkh
Copy link

conkerkh commented Oct 6, 2023

Environment

  • OS and Version: checked on Ubuntu 23 and MacOS
  • VS Code Version: 1.83.0
  • C/C++ Extension Version: 1.17.5
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:
cpptools-srv is crashing in some C++ files, looking at the stack trace of a crashing thread it might have something to do with templates but I'm not sure. It's impossible to hover over some types of data in C++ sources (hovering over them will crash cpptools-srv)

Steps to reproduce:
Hover over anything in a C++ source that doesn't get parsed correctly by cpptools-srv

Expected behavior:
Get a usual Intellisense prompt

Configuration and Logs

c_cpp_properties.json contains path to g++ executable and path to compile_commands.json file, C files and some C++ files are working correctly so configuration is unlikely not an issue

"cpptools-srv" received signal SIGSEGV, Segmentation fault.

set_node_operator(an_expr_node*, an_expr_operator_kind, a_type*, int, an_expr_node*) (Unknown Source:0)
make_operator_node(an_expr_operator_kind, a_type*, an_expr_node*) (Unknown Source:0)
build_binary_result_operand_full(an_operand*, an_operand*, an_expr_operator_kind, a_type*, int, an_operand*) (Unknown Source:0)
do_binary_operation_full(an_expr_operator_kind, an_operand*, an_operand*, a_type*, int, an_operand*, a_source_position*, unsigned int, a_source_position*) (Unknown Source:0)
scan_subscript_operator(an_operand*, int, a_rescan_control_block*, an_operand*) (Unknown Source:0)
scan_expr_full(an_operand*, an_operand*, int, int) (Unknown Source:0)
scan_void_expression(int, int, int, a_dynamic_init**, an_init_component*) (Unknown Source:0)
expression_statement(int) (Unknown Source:0)
statement(int, int) (Unknown Source:0)
compound_statement_full(int, int, int, int, int, a_type**) (Unknown Source:0)
statement(int, int) (Unknown Source:0)
if_statement() (Unknown Source:0)
statement(int, int) (Unknown Source:0)
compound_statement_full(int, int, int, int, int, a_type**) (Unknown Source:0)
scan_function_body(a_routine*, a_func_info_block*, unsigned long, a_macro_arg_fixup**, a_macro_arg_fixup**) (Unknown Source:0)
function_prototype_instantiation(a_symbol*) (Unknown Source:0)
process_deferred_class_fixups(int) (Unknown Source:0)
process_deferred_class_fixups_and_instantiations(int) (Unknown Source:0)
template_declaration(a_tmpl_decl_state*, int*) [clone .constprop.0] (Unknown Source:0)
template_or_specialization_declaration_full(a_tmpl_decl_state*, int, a_decl_parse_state*) (Unknown Source:0)
template_or_specialization_declaration(a_token_kind*, int, a_source_position*, int, a_decl_parse_state*) (Unknown Source:0)
template_directive_or_declaration(a_token_kind*, int, a_source_position*) (Unknown Source:0)
scan_nonmember_declaration(a_decl_parse_state*, a_source_range*) (Unknown Source:0)
declaration(int, int, int, int, a_param_id*, a_source_range*, a_decl_parse_state*) [clone .constprop.0] (Unknown Source:0)
namespace_declaration(a_token_kind*, int, int, a_source_position*, a_symbol**) (Unknown Source:0)
namespace_declaration(a_token_kind*, int, int, a_source_position*, a_symbol**) (Unknown Source:0)
scan_nonmember_declaration(a_decl_parse_state*, a_source_range*) (Unknown Source:0)
declaration(int, int, int, int, a_param_id*, a_source_range*, a_decl_parse_state*) [clone .constprop.0] (Unknown Source:0)
translation_unit() (Unknown Source:0)
process_translation_unit(char const*, int, an_exported_template_file*) (Unknown Source:0)
cfe_main(int, char**) (Unknown Source:0)
cfe_main_exception_handler(int, char**) (Unknown Source:0)
edg_main(int, char**) (Unknown Source:0)
invoke_edge_compiler(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)
edge_compiler_main(int, char const**) (Unknown Source:0)
a_compiler_thread::compiler_thread_routine(a_compiler_thread*) (Unknown Source:0)
msvc::thread_helper_t::thread_entry(void*) (Unknown Source:0)
start (Unknown Source:0)
[Unknown/Just-In-Time compiled code] (Unknown Source:0)

cpptools gracefully exits/restarts so it's related to cpptools-srv

IntelliSense process crash detected.
IntelliSense process crash detected.
IntelliSense process crash detected.
IntelliSense process crash detected.
IntelliSense process crash detected.
IntelliSense process crash detected.
IntelliSense process crash detected.

Other Extensions

No response

Additional context

No response

@Colengms
Copy link
Collaborator

Colengms commented Oct 6, 2023

Hi @conkerkh . Thanks for letting us know. Could isolate the issue into a code example that reproduces the problem, which we could use to investigate further?

@Colengms Colengms self-assigned this Oct 6, 2023
@Colengms Colengms added Language Service more info needed The issue report is not actionable in its current state labels Oct 6, 2023
@conkerkh
Copy link
Author

conkerkh commented Oct 6, 2023

I would be happy to help here, however I can't easily reproduce this problem. It's crashing only in one of my projects, and I have no clue how to find out which header is causing this issue. If you have any suggestion how to get information from gdb where exactly it fails I could try to write a sample code that reproduces the problem. Debug info from C/C++ plugin doesn't say much

@Colengms
Copy link
Collaborator

Colengms commented Oct 6, 2023

Hi @conkerkh . The crash would be related to code in the file open at the time, or one of the headers it includes, and possibly related to what is being hovered over.

I'd suggest temporarily reducing the source file to only a small bit of code. If the issue repro's, start removing unused headers. Alternatively, you might try generating a preprocessed file (i.e. using the -E argument to g++). If the issue occurs within that file, reducing it would involve stripping out code from the end until the repro is removed, then putting that code back and removing code prior to it that's unrelated. Generally, this process should result in just the specific syntax triggering the issue. Or, if you can reduce a preprocessed file enough that you're comfortable sharing its contents, we could reduce it further.

@conkerkh
Copy link
Author

conkerkh commented Oct 6, 2023

I managed to reproduce it with this piece of code:

#include <cstdint>

namespace Test
{
    typedef void (*error_callback)();

    template <uint32_t T>
    class SomeClass {
    private:
        static error_callback _cb;

    public:
        void Something()
        {
            if (T == 0x2000) {
                _cb[0] = nullptr;
            }
        }
    };
};   

int main()
{
    return 0;
}

This code has some mistakes.
If you look at it, _cb[0] doesn't make much sense, and should be marked as an error. Instead, I believe it is the main reason why the cpptools-srv crashes.

It may be possible that the if statement inside "Something" doesn't make a difference.

@Colengms
Copy link
Collaborator

Colengms commented Oct 7, 2023

Hi @conkerkh . Thanks for the reduced code. Unfortunately, I'm not able to reproduce a crash with this code, with 1.17.5 of the C/C++ Extension, on either Ubuntu (w/clang-16) or on macOS. If you create a fresh folder and move this code into it, does the crash still repro for you? Is there anything else (other than hovering over the various identifiers) that you are doing that may be necessary to repro the crash? It's possible there may be some details about your configuration, or C_Cpp related settings, that I may need to set as well to repro. Can you provide that information as well?

@conkerkh
Copy link
Author

conkerkh commented Oct 7, 2023

I used GCC compilers, so if you select g++ for compilerPath in c_cpp_properties.json file it should work with this example. Looks like clang will mark the line with _cb[0] as an error.

For this example:

    "configurations": [
        {
            "name": "Test",
            "compilerPath": "/usr/local/bin/g++-13",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x86",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "defines": [],
        }
    ],
    "version": 4
}```

@Colengms
Copy link
Collaborator

Hi @conkerkh . Thanks for the clarification. I can reproduce the crash when using a GGC intelliSense mode on Linux. We will investigate further.

@Colengms Colengms added investigate: repro This issue's repro steps needs to be investigated/confirmed bug and removed more info needed The issue report is not actionable in its current state labels Oct 13, 2023
@Colengms Colengms added this to the 1.19 milestone Oct 13, 2023
@sean-mcmanus sean-mcmanus added fixed Check the Milestone for the release in which the fix is or will be available. Visual Studio Inherited from Visual Studio and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Nov 6, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.19, 1.18.2 Nov 6, 2023
@sean-mcmanus
Copy link
Collaborator

@github-actions github-actions bot locked and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

3 participants