microsoft / microsoft/vscode-cpptools

Empty string in args throws IndexOutOfRangeException since v1.1.0

Open
#6,522 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Type: Debugger

Since version 1.1.0 having empty strings in the args array will give an IndexOutOfRangeException when trying to Start Debugging. This worked fine in version 1.0.1.
Issue: In launch.json "args":[ "a","","","b"]
Workaround: add extra escaped quotes in empty argument "args":[ "a","\"\"","\"\"","b"],

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.51.1
  • C/C++ Extension Version: 1.1.1
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

Running the debugger will give a popup with title "Visual Studio Code" and error:

Unable to start debugging. Internal error in MIEngine. Exception of type 'System.IndexOutOfRangeException' was thrown.

at MICore.LaunchOptions.QuoteArgument(String arg)
at MICore.LaunchOptions.ParseArguments(IEnumerable`1 arguments, Boolean quoteArguments)
at MICore.LaunchOptions.InitializeLaunchOptions(LaunchOptions launch)
at MICore.LocalLaunchOptions.CreateFromJson(JObject parsedOptions)
at MICore.LaunchOptions.GetInstance(HostConfigurationStore configStore, String exePath, String args, String dir, String options, Boolean noDebug, IDeviceAppLauncherEventCallback eventCallback, TargetEngine targetEngine, Logger logger)
at Microsoft.MIDebugEngine.AD7Engine.Microsoft.VisualStudio.Debugger.Interop.IDebugEngineLaunch2.LaunchSuspended(String pszServer, IDebugPort2 port, String exe, String args, String dir, String env, String options, enum_LAUNCH_FLAGS launchFlags, UInt32 hStdInput, UInt32 hStdOutput, UInt32 hStdError, IDebugEventCallback2 ad7Callback, IDebugProcess2& process)

To Reproduce

{
      "name": "classic 1",
      "type": "cppdbg",
      "request": "launch", 
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "args":[ "a","","","b"],
      "stopAtEntry": true,
      "cwd": "${workspaceFolder}",
      "externalConsole": true,
      "MIMode": "gdb",
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the launch.json args array shown in the issue and inspect the reported MICore.LaunchOptions.QuoteArgument and ParseArguments stack frames. Compare behavior with version 1.0.1 and 1.1.1; done means empty arguments start debugging without an IndexOutOfRangeException and the existing argument values are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.