microsoft / microsoft/vscode-cpptools

Locals in Variables spinning forever when the below attached program is debugged

Aperta
#12,800 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

debugger help wanted
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and version: macos
  • VS Code: 1.93.1
  • C/C++ extension: v1.21.6
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: lldb-1500.0.404.7
    Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Run the below program in gdb debugger
  2. set break at function subarr
  3. when breakpoint is hit, the locals variable starts to spin
Debugger Configurations
{
    "tasks": [
        {
            "label": "compile and run cpp",
            "type": "shell",
            "command": "g++ -std=c++17 -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run no input",
            "type": "shell",
            "command": "g++ -std=c++17 -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension}",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run c",
            "type": "shell",
            "command": "gcc -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run python",
            "type": "shell",
            "command": "python3 ${file} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang build active file",
            "command": "/usr/bin/clang",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
Debugger Logs
This is no launch.json file
Other Extensions

No response

Additional Information

Program being run
`#include <bits/stdc++.h>

int subarr(vector& nums, int p) {
int sum = 0;
int sz = nums.size();
for (int i = 0; i < sz; i++)
{
sum+=nums[i];
}
int target = sum % p;
unordered_map<int, int> umap; //<csum, idx>
umap[0] = -1;
int csum = 0;
int res = INT_MAX;
for (int i = 0; i < sz; i++)
{
csum += nums[i];
int other_half = (csum % p - target + p) % p;
if (umap.find(other_half) != umap.end())
{
res = min(res, i - umap[other_half]);
}
umap[csum] = i;
}
return res != INT_MAX ? res : -1;
}

int main(int argc, char const *argv[])
{
vector v{3,1,4,2};
int p = 6;
auto res = subarr(v, p);
cout << res << endl;
return 0;
}
`
Screenshot 2024-10-03 at 10 39 55 PM

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema con il programma C++ allegato, imposta un punto di interruzione in subarr e osserva la vista Locals quando l'esecuzione si interrompe. Controlla prima la configurazione del debugger e i log disponibili; l'attività è completata quando la vista Locals viene visualizzata invece di continuare a girare indefinitamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, vscode
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.