microsoft / microsoft/vscode-cpptools

Inconsistent expression evaluation result if type name conflicts with variable name

Open
#8,241 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Debugger

  • OS and Version: Windows 10
  • VS Code Version: 1.60.1
  • C/C++ Extension Version: 1.6.0

Source C code to reproduce (compiled with cl.exe /Zi)

typedef struct foo {
    int a;
} foo_t;

foo_t foo;

int main(int argc, char *argv[])
{
    return foo.a;
}

Steps to reproduce the behavior:

  1. Set a breakpoint in main
  2. Start debugging
  3. In debug console type foo twice, and the result is different

It seems that the evaluation result of foo for the second time is "class" instead of "data"
The first evaluation result:
foo
-> (C) {"command":"evaluate","arguments":{"expression":"foo","frameId":1000,"context":"repl"},"type":"request","seq":17}
<- (R) {"seq":711,"type":"response","request_seq":17,"success":true,"command":"evaluate","body":{"result":"{a=0 }","type":"foo","presentationHint":{"kind":"data","attributes":["readOnly","static"]},"variablesReference":1003,"evaluateResponseReference":1003}}

The second evaluation result:
-> (C) {"command":"evaluate","arguments":{"expression":"foo","frameId":1000,"context":"repl"},"type":"request","seq":20}
<- (R) {"seq":720,"type":"response","request_seq":20,"success":true,"command":"evaluate","body":{"result":"","presentationHint":{"kind":"class","attributes":["readOnly"]},"variablesReference":0,"evaluateResponseReference":1007}}

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

Start by reproducing the issue in the VS Code debug console with the provided C source and cl.exe /Zi, then inspect how repeated evaluate requests for foo are handled. Compare the first and second responses, especially presentationHint and variablesReference; done means repeated evaluation consistently reports the variable data rather than a class.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.