Type: Debugger
Describe the bug
CMake -> the issue still persists after uninstalling it A clear and concise description of what the bug is:
While debugging, when I hover over the iterator of std::unordered_map the debugger fails with the following error:
To Reproduce
launch.json configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/vscode/program.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\CLI\\gcc-tools\\mingw-w64\\x86_64-8.1.0-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "build & debug",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "build (cmake)",
"program": "${workspaceFolder}/bin/vscode/program.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\CLI\\gcc-tools\\mingw-w64\\x86_64-8.1.0-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Steps to reproduce the behavior:
Consider the following short snippet:
for (auto iterator = selections.begin(); iterator != selections.end(); ++iterator)
{
if (iterator->first == name && iterator->second == list)
{
iterator = selections.erase(iterator);
}
}
Everytime when I hover over first and second the debugger crashes. I tested this in different parts of the code and it seems to be the case all the time. If I do not hover, but continue to step over, everything works as expected.
Re-installing the extension did not help.
Additional context
Debug console output:
=thread-group-added,id="i1"
GNU gdb (GDB) 8.1
Copyright (C) 2018 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:
<http://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 18040.0x5114]
[New Thread 18040.0x2e60]
[New Thread 18040.0x2b78]
Thread 1 hit Breakpoint 1, main () at C:\Users\Mihai\Desktop\folder\folder\Console\src\Console.cpp:10
10 LOG("Console starting...");
Thread 1 hit Breakpoint 2, engine::ItemSelecting::MoveItemToList (item=..., from=..., to=...) at C:\Users\Mihai\Desktop\folder\folder\Engine\src\syntax\ItemSelecting.cpp:79
79 RemoveFromActiveSelections(itemName, from.type);
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\msvcrt.dll'. Symbols loaded.
Loaded 'C:\CLI\gcc-tools\mingw-w64\x86_64-8.1.0-posix-sjlj-rt_v6-rev0\mingw64\opt\bin\libgcc_s_sjlj-1.dll'. Symbols loaded.
Loaded 'C:\CLI\gcc-tools\mingw-w64\x86_64-8.1.0-posix-sjlj-rt_v6-rev0\mingw64\opt\bin\libwinpthread-1.dll'. Symbols loaded.
Loaded 'C:\CLI\gcc-tools\mingw-w64\x86_64-8.1.0-posix-sjlj-rt_v6-rev0\mingw64\bin\libstdc++-6.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\user32.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\win32u.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\gdi32.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\gdi32full.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\msvcp_win.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\ucrtbase.dll'. Symbols loaded.
Loaded 'C:\WINDOWS\System32\imm32.dll'. Symbols loaded.
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
Stopping due to fatal error: AggregateException: One or more errors occurred.
Any ideas what may case this? Thanks!
@mihaiconstantin Can you remove -enable-pretty-printing and see if it still reproduces?
Edit: Never mind. I was able to get a repro for this.
@mihaiconstantin if you enable engineLogging in your launch.json can you confirm what I see?
When I tried your scenario, I'm showing the problem is that gdb is crashing.
1: (5759) <-1034-var-create - * "iterator->first"
1: (5804) "z:\mingw\mingw64\bin\gdb.exe" exited with code -1073741819 (0xC0000005).
If that is what you see too, that's a toolset issue.
@pieandcakes Thanks for the quick reply and suggestions. Based on your reply, here is a summary of the things I have tried:
-enable-pretty-printing: it still reproducesengineLogging: error still reproduces, however, I cannot get the exit code you indicatedI tried the following, and it still fails:
std::vector<Foo> vectorFoo;
const auto first = std::find_if(vectorFoo.begin(), vectorFoo.end(), [&name](const Foo& foo) { return foo.name == name; });
first; // Works ok.
*first; // Fails on hover.
&(*first); // Fails on hover.
And the debug console output indicates:
1: (17508) ->(gdb)
1: (22048) <-1073-var-create - * "*first"
Stopping due to fatal error: AggregateException: One or more errors occurred.
Ok. I tried with the unordered map. I can try it with your vector example. Its usually easier for me to reproduce if you provide a whole code sample with the issue.
What is Foo in your example?
My apologies for the delay in answering your question. I prepare a short example for you to reproduce.
class Foo
{
public:
std::string key;
int value;
Foo(const std::string& key, const int& value);
};
Foo::Foo(const std::string& key, const int& value)
: key(key), value(value)
{
std::cout << "Created Foo." << "\n";
}
With the following usage:
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
int main()
{
std::vector<Foo> collection {
{ "test 0", 0 },
{ "test 1", 1 },
{ "test 2", 2 },
{ "test 3", 3 }
};
std::string key = "test 1";
const auto predicate = [&key](const Foo& foo) { return foo.key == key; };
const auto first = std::find_if(collection.begin(), collection.end(), predicate);
first; // Works ok.
*first; // Fails on hover.
&(*first); // Fails on hover.
}
With the following output in the debug console:
1: (9169) <-1062-var-create - * "*first"
Stopping due to fatal error: AggregateException: One or more errors occurred.
@mihaiconstantin The AggregateException ends up revealing the gdb error. I forgot I had https://github.com/Microsoft/MIEngine/pull/826 applied. I've gotten a fix for showing the actual error, but the problem is that the 64bit version of MinGW's 8.1 gdb is buggy and is crashing when we ask it to evaluate. I tried the 8.1 32bit version and it SIGSEVs as soon as I hover. I then tested with the Windows Subsystem Linux with the same code and our extension the hover works fine. This leads me to believe that the toolset issue (gdb on MinGW) is causing issues and it isn't our code.
The fix to reveal the actual error will be in our future release.
@pieandcakes Thanks a lot for the information. I tried it and, indeed, it seems to work well with the Windows Subsystem Linux. I will take a look at the fix that allows for seeing the actual error. Shall I close this issue?
Thanks for checking. I'll close it. Thanks