Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopping due to fatal error: ArgumentException: An item with the same key has already been added. #8760

Closed
ninok opened this issue Feb 2, 2022 · 30 comments
Assignees
Labels
debugger fixed Check the Milestone for the release in which the fix is or will be available. regression A bug that didn't exist in a previous release
Milestone

Comments

@ninok
Copy link

ninok commented Feb 2, 2022

Bug type: Debugger

Describe the bug

  • OS and Version: MacOS 11.6.3 with remote ssh to Amazon Linux 2
  • VS Code Version: 1.63.2
  • C/C++ Extension Version: 1.8.3
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

I cannot execute any gdb command in the debug console anymore.
When I for example do -exec ptype geometry1
I get: Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, geometry1)
The variable name in the error message seems unrelated to my command. It also happens when I add breakpoints through debug console. It seems to always be the first local variable in the call stack that is mentioned in the error message.

Interesting to note though: The actual command succeeds and I can see the output of ptype. The error/crash happens just after.

Additional context
I cannot include full trace here for legal reasons.
Last messages before the crash are:

--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Evaluate","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"17.1.20131.1","VS.Diagnostics.Debugger.HostVersion":"17.1.20131.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Evaluate.Duration":1615.0,"VS.Diagnostics.Debugger.Evaluate.IsError":false,"VS.Diagnostics.Debugger.Evaluate.ExecuteInConsole":true}},"seq":2275}
--> R (evaluate-25): {"type":"response","request_seq":25,"success":true,"command":"evaluate","body":{"result":"","variablesReference":0},"seq":2277}
<--   C (scopes-26): {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":26}
--> R (scopes-26): {"type":"response","request_seq":26,"success":true,"command":"scopes","body":{"scopes":[{"presentationHint":"locals","name":"Locals","variablesReference":1010,"expensive":false},{"presentationHint":"registers","name":"Registers","variablesReference":1011,"expensive":true}]},"seq":2280}
<--   C (variables-27): {"command":"variables","arguments":{"variablesReference":1010},"type":"request","seq":27}
@jmazar
Copy link

jmazar commented Feb 2, 2022

I'm having the same error.

@ruabmbua
Copy link

ruabmbua commented Feb 2, 2022

Have the same error here. Seems like it is unsupported to have the same variable name twice in a stack frame, which is of course possible in e.g. C++

Renaming the duplicate variable names in nested blocks solves the debugger hang.

@ruabmbua
Copy link

ruabmbua commented Feb 2, 2022

Hm seems like there is something else going on as well. Only managed to debug a little further, but now the same error, but there are not multiple variables with same name on the same stack frame.

@markrussell-cpu
Copy link

I'm having the same errors.

@ruabmbua
Copy link

ruabmbua commented Feb 2, 2022

Strangely enough downgrading the extension does not help?

Edit: Managed to downgrade to last release version 1.7.1, which resolves the bug. It auto updated before, and I did not notice.

@sean-mcmanus sean-mcmanus pinned this issue Feb 2, 2022
@calgagi calgagi self-assigned this Feb 2, 2022
@ninok
Copy link
Author

ninok commented Feb 2, 2022

Yes, forgot to mention that this is a regression that was introduced recently. It was working last week. I did not bisect when exactly it was introduced.
With this regression debugging is impossible for me so I will also downgrade.

@ninok
Copy link
Author

ninok commented Feb 2, 2022

Regarding duplicate variable names: In my case I have a pretty trivial function that has only some local vars with different names but it's still crashing.

@calgagi
Copy link

calgagi commented Feb 2, 2022

The problem is with some variable caching I did for supporting data breakpoints in MIEngine: microsoft/MIEngine#1257

I've got a fix working now. The Debug Adapter Protocol has a small issue where we only send the variable name and the stack frame it's associated with (or the parent variable if it's a child), so I'm just converting the cache's dictionaries to use TryAdd methods instead as a quick fix.

@mdemoret-nv
Copy link

mdemoret-nv commented Feb 2, 2022

@calgagi Do you know which version(s) this affects? Should we be downgrading to 1.7.1 or is there a pre-release version that should work?

Edit: Looks like its still an issue in pre-release 1.8.3

@mdemoret-nv
Copy link

One other thing I noticed: this seems to break removing breakpoints for me. Even after clicking in the source code to remove a breakpoint, gdb still stops at that line.

@sean-mcmanus
Copy link
Contributor

@mdemoret-nv 1.8.3 is identical to 1.8.2. You should try our previous Insiders -- 1.8.1, which has older debugger binaries.

@calgagi
Copy link

calgagi commented Feb 2, 2022

Anytime we evaluate a variable more than once (in the same break state while debugging) or stop when there are 2 or more variables with the same name, the debugger will crash. The variable(s) must be in the same stack frame.

@ruabmbua
Copy link

ruabmbua commented Feb 4, 2022

Its funny, even calling -exec p <varname> will cause the issue. Was not aware that the debugger plugin also looks into the raw gdb commands.

@WardenGnaw WardenGnaw added the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 4, 2022
@aakash0641
Copy link

@WardenGnaw @WardenGnaw I switched C/C++ version to 1.8.1. and issue still persists. So I downgraded it further to 1.7.1 and issue still persists. Can you help please ?
Screenshot from 2022-02-05 08-17-22

@aakash0641
Copy link

@WardenGnaw Providing output from Debug Console: (replying here as you closed #8776
Screenshot from 2022-02-05 08-23-16

@RobertoMex
Copy link

Switch to 1.7.1 close VSCode and re open VSCode. Just worked for me.

@aakash0641
Copy link

@mdemoret-nv 1.8.3 is identical to 1.8.2. You should try our previous Insiders -- 1.8.1, which has older debugger binaries.

I tried downgrading C/C++ up till 1.7.1 and issue is still present. Hey, what is Insiders? Is it something different from C/C++ extension? I was getting popup messages in VSCode regarding installing insiders. I didn't downgrade Insiders specifically. I searched for it in list of installed extensions but could not locate it. Any help please?

@aakash0641
Copy link

aakash0641 commented Feb 5, 2022

Switch to 1.7.1 close VSCode and re open VSCode. Just worked for me.

Didn't work for me. I even restarted my laptop to avoid any trace of running processes.
Screenshot from 2022-02-05 08-42-40
Screenshot from 2022-02-05 08-43-57

@lipracer
Copy link

lipracer commented Feb 5, 2022

After I update the vscode version to latest I get the same error.An item with the same key has already been added. Key:

@aakash0641
Copy link

@WardenGnaw As in by Debug Console, there is no error shown, so it seems that the issue I am facing is not same as #8760 . In that case, I request you to re-open issue #8776 and help.

@briaguya-ai
Copy link

briaguya-ai commented Feb 6, 2022

i am also running into this issue, i'll update this comment when the fix is released and I've tested it

edit: fixed for me in v1.8.5 Pre-Release

@zeroxia
Copy link

zeroxia commented Feb 7, 2022

I got this error when debugging.

System: Ubuntu 18.04

VSCode version:

Version: 1.63.2
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:39:46.686Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.4.0-97-generic

C/C++ tools extension: v1.8.3 Pre-Release

Workspace is in a running docker container.

An rec error message in Debug console is shown:
Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, __func__)

Then the debug cannot continue. I have to click the stop button to end the session, other buttons (continue, stepping etc) do not work anymore.

@KindHeartedTraveler
Copy link

system: Ubuntu 20.04.1
vscode version: 1.64.0

I have the same problem when debug the OpenJdk source code. I can't delete breakpoints in vscode editor area. So i run the commands in the DEBUG CONSOLE then get this problem.

The old version, 1.8.1 or 1.7.1 version works well. Make sure disable auto update extensions.

@PeacefulWhale
Copy link

PeacefulWhale commented Feb 7, 2022

System: macOS Monterey: 12.1 (21C52)
VSCode Version: 1.64.0
C/C++ Extension Version: 1.8.2 Release Version

I ran into the same problem.

I wrote this small C code to see if I could narrow it down, and it turns out that it's happening with almost everything.

#include <stdlib.h>
#include <stdio.h>

typedef struct test
{
    int i;
    // struct test *next;
} test;

int main()
{
    test first;
    first.i = 0;

    struct second
    {
        int i;
    } second;
    second.i = 1;

    int third = 0;

    // BREAKPOINT HERE.

    return 0;
}

Debugging any of the values (first.i, second.i, third) returns the same error:

Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, first)

I decided to see what would happen if I removed the first element, by commenting everything out.

This changed the error to:

Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, second)

I then commented out the second, and called the third item again.

Which then changed the problem to:

Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, second)

Even something as simple as:

int main()
{
    int third = 0;
    // BREAKPOINT HERE.
    return 0;
}

will cause the error.

I don't have the time to try to figure it out right now, so I'll just switch to the later version.

Hopefully I'll be able to come back and help with it. I'm sorry if this information isn't useful and just clutters up this page.

Here is everything from the debugger:

Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=thread-selected,id="1"
=library-unloaded,id="[/Users/mikecabatingan/Desktop/Programming/Misc/Temp/test.compiled]()",target-name="[/Users/MYNAME/Desktop/Programming/Misc/Temp/test.compiled]()",host-name="[/Users/MYNAME/Desktop/Programming/Misc/Temp/test.compiled]()"
Loaded '[/usr/lib/dyld]()'. Symbols loaded.
Loaded '[/Users/MYNAME/Desktop/Programming/Misc/Temp/test.compiled]()'. Symbols loaded.
Loaded '[/usr/lib/libSystem.B.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libcache.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libcommonCrypto.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libcompiler_rt.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libcopyfile.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libcorecrypto.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libdispatch.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libdyld.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libkeymgr.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libmacho.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libquarantine.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libremovefile.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_asl.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_blocks.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_c.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_collections.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_configuration.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_containermanager.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_coreservices.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_darwin.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_dnssd.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_featureflags.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_info.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_m.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_malloc.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_networkextension.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_notify.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_product_info_filter.dylib]()'. Cannot find or open the symbol file.
Loaded '[/usr/lib/system/libsystem_sandbox.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_secinit.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_kernel.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_platform.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_pthread.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_symptoms.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libsystem_trace.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libunwind.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/system/libxpc.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/libc]()++abi.dylib'. Symbols loaded.
Loaded '[/usr/lib/libobjc.A.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/liboah.dylib]()'. Symbols loaded.
Loaded '[/usr/lib/libc]()++.1.dylib'. Symbols loaded.
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
third
0
Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, third)

Putting anything into the debugger (even if it's not "legal" and would return an error anyway) causes the same problem to occur, for example:

garbageIn
error: <user expression 0>:1:1: use of undeclared identifier 'garbageIn'
garbageIn
^
Stopping due to fatal error: ArgumentException: An item with the same key has already been added. Key: (Microsoft.MIDebugEngine.AD7StackFrame, third)

@PeacefulWhale
Copy link

I've confirmed that this issue still exists in 1.8.3

@sean-mcmanus
Copy link
Contributor

@PeacefulWhale 1.8.3 is identical to 1.8.2 (VS Code is requiring that we release 2 identical versions of our extension in order to support the Pre-Release channel, see the discussion at microsoft/vscode#142040). The fix is expected to be in our 1.8.4/1.8.5 release later today.

@PeacefulWhale
Copy link

@sean-mcmanus

Ah, thank you, I wasn’t aware of the practice.

Thank you for your work!

@lucasexe
Copy link

lucasexe commented Feb 8, 2022

I've also was been facing this issue but I've just checked the new release and the issue is gone!

Thanks for the quick fix :)

@sean-mcmanus
Copy link
Contributor

Yes, it's fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.8.4 (or 1.8.5, which is identical, except using that version will auto-update to 1.9.0 (insiders) when we release that).

@perrog
Copy link

perrog commented Feb 10, 2022

My workaround has been to collapse the Variables view and prevent evaluation of variables while stepping. (If it happens again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger fixed Check the Milestone for the release in which the fix is or will be available. regression A bug that didn't exist in a previous release
Projects
None yet
Development

No branches or pull requests