microsoft / microsoft/vscode-cpptools
GDB hangs when pasting into the terminal before a `scanf` call
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and version: Windows 10 19044.2846
- VS Code: 1.77.3
- C/C++ extension: 1.14.5
- OS and version of remote machine (if applicable): None
- GDB / LLDB version: GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 13.1
Bug Summary and Steps to Reproduce
Bug Summary: When using the GDB from MinGW-W64 and debugging a program, if I paste some input into the terminal before the control flow reaches a scanf call, the debugger hangs after the scanf call as if it's stuck in an infinite loop.
Steps to reproduce:
- Download GCC 12.2.0 + LLVM/Clang/LLD/LLDB 16.0.0 + MinGW-w64 10.0.0 (UCRT) - release 5 for Win64 from winlibs.com.
- Debug this program
#include <stdio.h>
int main(void)
{
size_t height = 0, width = 0;
scanf("%zu %zu", &height, &width);
int maze[height][width];
}
with the play button and select the compiler you just downloaded, with a breakpoint at line 6(at the scanf). No launch.json or task.json required.
- When the execution stops at line 6, paste this line into the terminal:
1 1
- Press step over and observe that the debugger just hangs.
Debugger Configurations
None
Debugger Logs
=thread-group-added,id="i1"
GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 14560.0x49dc]
Thread 1 hit Breakpoint 1, 0x00007ff6fdaf17ea in main () at D:\Desktop\C\College\Portal\Portal1.c:4
4 {
Loaded 'C:\WINDOWS\SYSTEM32\ntdll.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\kernel32.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\KernelBase.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\ucrtbase.dll'. Symbols loaded.
Thread 1 hit Breakpoint 2, main () at D:\Desktop\C\College\Portal\Portal1.c:6
6 scanf("%zu %zu", &height, &width);
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
Other Extensions
No response
Additional Information
This problem doesn't occur if I use the GDB that came with TDM-GCC 10.3.0.
settings.json:
{
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
"editor.formatOnType": false,
"editor.cursorSmoothCaretAnimation": "on",
"editor.fontFamily": "Monocraft",
"editor.fontSize": 15,
"editor.fontLigatures": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 0,
"terminal.integrated.fontFamily": "Monocraft",
"terminal.integrated.fontSize": 11,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"workbench.statusBar.visible": true,
"editor.smoothScrolling": true,
"editor.cursorBlinking": "smooth",
"security.workspace.trust.untrustedFiles": "open",
"workbench.editor.untitled.hint": "hidden",
"files.autoGuessEncoding": true,
"python.analysis.typeCheckingMode": "strict",
"powermode.enabled": false,
"redhat.telemetry.enabled": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.inlineSuggest.enabled": true,
"security.workspace.trust.startupPrompt": "always",
"security.workspace.trust.banner": "always",
"security.workspace.trust.enabled": false,
"workbench.iconTheme": "material-icon-theme",
"files.associations": {
"*.txt": "log"
},
"json.maxItemsComputed": 32648,
"[cpp]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"editor.renderWhitespace": "none",
"editor.bracketPairColorization.enabled": false,
"code-runner.executorMap": {
"c": "cd $dir && gcc \"$fileName\" -o (\"$fileNameWithoutExt\" + \".exe\") -std=c17 -Wall -Wextra -pedantic -O2 && & (\"$dir$fileNameWithoutExt\" + \".exe\")",
"cpp": "cd $dir && g++ \"$fileName\" -o (\"$fileNameWithoutExt\" + \".exe\") -std=c++17 -Wall -Wextra -pedantic -O2 && & (\"$dir$fileNameWithoutExt\" + \".exe\")"
},
"code-runner.executorMapByFileExtension": {
".m": "cd $dir && matlab -batch \"$fileNameWithoutExt\""
},
"code-runner.runInTerminal": true,
"code-runner.clearPreviousOutput": false,
"code-runner.preserveFocus": false,
"terminal.integrated.enableMultiLinePasteWarning": false,
"[c]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.cursorBlinking": true,
"[matlab]": {
"editor.defaultFormatter": "AffenWiesel.matlab-formatter"
},
"matlab.lintOnSave": true,
"matlab.mlintpath": "D:\\MATLAB\\bin\\win64\\mlint.exe",
"explorer.confirmDelete": false,
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.errorSquiggles": "disabled",
"C_Cpp.default.compilerArgs": [
"-Wall",
"-Wextra",
"-pedantic"
],
"C_Cpp.loggingLevel": "Debug",
"debug.onTaskErrors": "showErrors",
"clangd.path": "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\bin\\clangd.exe",
"C_Cpp.intelliSenseEngine": "default",
"C_Cpp.autocomplete": "disabled",
"editor.inlayHints.enabled": "off",
"workbench.colorTheme": "Dracula",
"doxdocgen.generic.commandSuggestion": true,
"doxdocgen.c.triggerSequence": "///",
"doxdocgen.generic.commandSuggestionAddPrefix": true,
"clangd.detectExtensionConflicts": false,
"clangd.fallbackFlags": [
"-Weverything",
"-Wno-used-but-marked-unused",
"-Wno-declaration-after-statement",
"-Wno-vla",
"-Wno-missing-prototypes",
"-Wno-c++98-compat",
"-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include",
"-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include",
"-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed",
"-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include",
"-nostdinc",
"-target",
"x86_64-pc-windows-gnu"
],
"clangd.arguments": ["--log=verbose"],
"editor.acceptSuggestionOnEnter": "off",
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"editor.largeFileOptimizations": false,
"terminal.integrated.scrollback": 32768,
"editor.tokenColorCustomizations": { // Disables italics
"textMateRules": [
{
"scope": [
"comment",
"comment.block",
"comment.block.documentation",
"comment.line",
"constant",
"constant.character",
"constant.character.escape",
"constant.numeric",
"constant.numeric.integer",
"constant.numeric.float",
"constant.numeric.hex",
"constant.numeric.octal",
"constant.other",
"constant.regexp",
"constant.rgb-value",
"emphasis",
"entity",
"entity.name",
"entity.name.class",
"entity.name.function",
"entity.name.method",
"entity.name.section",
"entity.name.selector",
"entity.name.tag",
"entity.name.type",
"entity.other",
"entity.other.attribute-name",
"entity.other.inherited-class",
"invalid",
"invalid.deprecated",
"invalid.illegal",
"keyword",
"keyword.control",
"keyword.operator",
"keyword.operator.new",
"keyword.operator.assignment",
"keyword.operator.arithmetic",
"keyword.operator.logical",
"keyword.other",
"markup",
"markup.bold",
"markup.changed",
"markup.deleted",
"markup.heading",
"markup.inline.raw",
"markup.inserted",
"markup.italic",
"markup.list",
"markup.list.numbered",
"markup.list.unnumbered",
"markup.other",
"markup.quote",
"markup.raw",
"markup.underline",
"markup.underline.link",
"meta",
"meta.block",
"meta.cast",
"meta.class",
"meta.function",
"meta.function-call",
"meta.preprocessor",
"meta.return-type",
"meta.selector",
"meta.tag",
"meta.type.annotation",
"meta.type",
"punctuation.definition.string.begin",
"punctuation.definition.string.end",
"punctuation.separator",
"punctuation.separator.continuation",
"punctuation.terminator",
"storage",
"storage.modifier",
"storage.type",
"string",
"string.interpolated",
"string.other",
"string.quoted",
"string.quoted.double",
"string.quoted.other",
"string.quoted.single",
"string.quoted.triple",
"string.regexp",
"string.unquoted",
"strong",
"support",
"support.class",
"support.constant",
"support.function",
"support.other",
"support.type",
"support.type.property-name",
"support.variable",
"variable",
"variable.language",
"variable.name",
"variable.other",
"variable.other.readwrite",
"variable.parameter"
],
"settings": {
"fontStyle": ""
}
}
]
},
"settingsSync.ignoredSettings": [
"editor.fontSize"
],
"files.maxMemoryForLargeFilesMB": 16384,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"[latex]": {
"editor.defaultFormatter": "James-Yu.latex-workshop"
},
"latex-workshop.latex.recipes": [
{
"name": "latexmk (xelatex)",
"tools": [
"cd",
"xelatexmk"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "xelatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-xelatex",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "cd",
"command": "cd",
"args": [
"%DIR%"
]
}
],
"latex-workshop.latex.recipe.default": "latexmk (xelatex)",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.message.information.show": false,
"editor.unicodeHighlight.allowedLocales": {
"zh-hant": true
},
"workbench.startupEditor": "none",
"cmake.configureOnOpen": false,
"editor.minimap.enabled": false,
"codesnap.showWindowControls": false,
"codesnap.containerPadding": "0",
"codesnap.transparentBackground": true,
"codesnap.backgroundColor": "#FFFFFF",
"codesnap.boxShadow": "none",
"update.showReleaseNotes": false,
"git.autofetch": true,
"git.enableSmartCommit": true,
"gitlens.views.commits.showBranchComparison": false,
"gitlens.views.showRelativeDateMarkers": false,
"git.confirmSync": false
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied C program with VS Code 1.77.3, C/C++ extension 1.14.5, and MinGW-W64 GDB 13.1, following the terminal-paste and step-over sequence. Compare the behavior with the TDM-GCC GDB mentioned in the report and inspect the debugger's handling of pasted standard input. Done means identifying whether the extension or GDB causes the hang and confirming behavior after the relevant fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100