Vscode-cpptools: Omitting the "description" field from customLaunchSetupCommands or setupCommands element causes NullReferenceException

Created on 22 Aug 2019  路  5Comments  路  Source: microsoft/vscode-cpptools

Type: Debugger

Describe the bug

  • OS and Version: Debian 10
  • VS Code Version: 1.37.1
  • C/C++ Extension Version: 0.25.0

The debugger crashes with a NullReferenceException if the "description" field is missing from an element inside the "customLaunchSetupCommands" list (inside a launch.json configuration).

Debug console output (with all logging enabled):

Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object

This was not an issue in earlier versions of cpptools (<=0.24.1)

To Reproduce
example of launch.json wich causes the issue:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "customLaunchSetupCommands": [
                { "text": "target-run", "ignoreFailures": false }
            ],
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

The issue is fixed by adding the "description" field the element inside "customLaunchSetupCommands", like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "customLaunchSetupCommands": [
                { "text": "target-run", "description": "run target", "ignoreFailures": false }
            ],
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}
bug debugger fixed (release pending)

Most helpful comment

I confirm that adding "description" solves the problem, as such:

        {
            "name": "eme-cpp-launch",
            "type": "cppdbg",
            "request": "launch",
            "MIMode": "gdb",
            "program": "${workspaceRoot}/elemental_se/bin/eme",
            "setupCommands": [
                {"text": "set breakpoint pending on", "description": ""},
                {"text": "set print array on", "description": ""},
                {"text": "set print pretty on", "description": ""},
                {"text": "-enable-pretty-printing", "description": ""},
                {"text": "set target-async 1", "description": ""},
                {"text": "set print elements 5000", "description": ""},
                {"text": "set sysroot remote:/", "description": ""},
            ],
            "stopAtEntry": false,
            "args": [ "--test" ],
            "cwd": "${workspaceRoot}",
            "targetArchitecture": "x64",
            "externalConsole": false
        },

All 5 comments

Strange that this wasn't an issue before as I don't think anything changed here.

I confirm that adding "description" solves the problem, as such:

        {
            "name": "eme-cpp-launch",
            "type": "cppdbg",
            "request": "launch",
            "MIMode": "gdb",
            "program": "${workspaceRoot}/elemental_se/bin/eme",
            "setupCommands": [
                {"text": "set breakpoint pending on", "description": ""},
                {"text": "set print array on", "description": ""},
                {"text": "set print pretty on", "description": ""},
                {"text": "-enable-pretty-printing", "description": ""},
                {"text": "set target-async 1", "description": ""},
                {"text": "set print elements 5000", "description": ""},
                {"text": "set sysroot remote:/", "description": ""},
            ],
            "stopAtEntry": false,
            "args": [ "--test" ],
            "cwd": "${workspaceRoot}",
            "targetArchitecture": "x64",
            "externalConsole": false
        },

thanks for checking. I have a fix pending.

Reopen until we ship

Fixed with 0.25.1.

Was this page helpful?
0 / 5 - 0 ratings