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

While debugging using VSCode, execution goes into infinite loop. #8776

Closed
aakash0641 opened this issue Feb 4, 2022 · 19 comments
Closed

While debugging using VSCode, execution goes into infinite loop. #8776

aakash0641 opened this issue Feb 4, 2022 · 19 comments
Assignees

Comments

@aakash0641
Copy link

aakash0641 commented Feb 4, 2022

Bug type: Debugger

Describe the bug

  • OS and Version: Ubuntu 20.04
  • VS Code Version: 1.63
  • C/C++ Extension Version: v1.8.3
  • Other extensions you installed (and if the issue persists after disabling them): CMake tools, C/C++ Extension Pack, C,C++ Themes
  • A clear and concise description of what the bug is. Only in debug mode (not during Run-without-debug), the execution goes into infinite loop on stepping into a particular function call using F11/F10/F5. Even though I put a breakpoint explictly inside the function constrainedMatching (see attached image, line 53) but the control does not reach at that particular line during debug. Instead the execution goes into endless loop. On pressing pause icon, the debug does not stop. Only way is stop press the Stop icon. I had raised this issue with VSCode forum, but they said that the issue is with /extCpp Please see the link F11 or F10 in Debug mode over a particular function goes in endless loop vscode#142166

To Reproduce
Please include a code sample and launch.json configuration.
Steps to reproduce the behavior:
1.The code to produce bug is https://github.com/whoenig/libMultiRobotPlanning
2. Download the code from above link and follow instructions in it to configure and build using CMake in VSCode
3. Start debug mode using CMAKE tools extension in VSCode
4.
Screenshot from 2022-02-04 14-31-44
Reach the problematic line 53 (as shown in attached snap) which has function call. Press F11 / F10 / F5 and see the endless loop
5. Note that the function call is in a hpp file. That is, a function, which is defined within hpp file, is called inside the hpp file.

Additional context
If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json
Add any other context about the problem here including log or error messages in your Debug Console or Output windows.
Below is the content of launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            // "program": "enter program name, for example ${workspaceFolder}/a.out",
            "program": "${command:cmake.launchTargetPath}",
            "args": ["-i", "ifile_1.yaml", "-o", "ofile_1.yaml"],
            // "stopAtEntry": true,
            "justMyCode": false,
            "cwd": "${fileDirname}",
            // "environment": [],
            "environment": [
                {
                    // add the directory where our target was built to the PATHs
                    // it gets resolved by CMake Tools:
                    "name": "PATH",
                    "value": "$PATH:${command:cmake.launchTargetDirectory}"
                }
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
@WardenGnaw
Copy link
Member

Can you add the following to your launch.json and share the output from the Debug Console?

logging": { "engineLogging": true, "trace": true, "traceResponse": true }

@WardenGnaw WardenGnaw added debugger more info needed The issue report is not actionable in its current state labels Feb 4, 2022
@TheTrio
Copy link

TheTrio commented Feb 4, 2022

Was facing the same error. Here's what the I got

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

Here's a screenshot
unknown

VS Code version: 1.64.0

Was able to reproduce the issue on both Windows 10(C++ extension version 1.8.2) and Arch (C++ extension version: 1.8.3 Pre release)

It loops infinitely here

image

@WardenGnaw
Copy link
Member

This seems to be a duplicate of #8760

Can you downgrade to 1.8.1?

@WardenGnaw WardenGnaw added duplicate and removed more info needed The issue report is not actionable in its current state labels Feb 4, 2022
@TheTrio
Copy link

TheTrio commented Feb 4, 2022

Yup that does the trick. Thanks!

@aakash0641
Copy link
Author

aakash0641 commented Feb 5, 2022

@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
Author

Can you add the following to your launch.json and share the output from the Debug Console?

logging": { "engineLogging": true, "trace": true, "traceResponse": true }

Please see the below output from the Debug Console:
Screenshot from 2022-02-05 08-23-16

-> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (19547) ->=breakpoint-modified,bkpt={number="17",type="breakpoint",disp="keep",enabled="y",addr="0x00005555555780b0",func="libMultiRobotPlanning::NextBestAssignment<unsigned long, Location, libMultiRobotPlanning::Assignment<unsigned long, Location> >::constrainedMatching(std::set<std::pair<unsigned long, Location>, std::less<std::pair<unsigned long, Location> >, std::allocator<std::pair<unsigned long, Location> > > const&, std::set<std::pair<unsigned long, Location>, std::less<std::pair<unsigned long, Location> >, std::allocator<std::pair<unsigned long, Location> > > const&, std::set<unsigned long, std::less, std::allocator > const&, std::set<unsigned long, std::less, std::allocator > const&, std::map<unsigned long, Location, std::less, std::allocator<std::pair<unsigned long const, Location> > >&)",file="/home/aakash/Desktop/code/libMultiRobotPlanning/include/libMultiRobotPlanning/next_best_assignment.hpp",fullname="/home/aakash/Desktop/code/libMultiRobotPlanning/include/libMultiRobotPlanning/next_best_assignment.hpp",line="129",thread-groups=["i1"],times="1",original-location="next_best_assignment.hpp:129"}\n"},"seq":3263}
1: (19547) ->=breakpoint-modified,bkpt={number="17",type="breakpoint",disp="keep",enabled="y",addr="0x00005555555780b0",func="libMultiRobotPlanning::NextBestAssignment<unsigned long, Location, libMultiRobotPlanning::Assignment<unsigned long, Location> >::constrainedMatching(std::set<std::pair<unsigned long, Location>, std::less<std::pair<unsigned long, Location> >, std::allocator<std::pair<unsigned long, Location> > > const&, std::set<std::pair<unsigned long, Location>, std::less<std::pair<unsigned long, Location> >, std::allocator<std::pair<unsigned long, Location> > > const&, std::set<unsigned long, std::less, std::allocator > const&, std::set<unsigned long, std::less, std::allocator > const&, std::map<unsigned long, Location, std::less, std::allocator<std::pair<unsigned long const, Location> > >&)",file="/home/aakash/Desktop/code/libMultiRobotPlanning/include/libMultiRobotPlanning/next_best_assignment.hpp",fullname="/home/aakash/Desktop/code/libMultiRobotPlanning/include/libMultiRobotPlanning/next_best_assignment.hpp",line="129",thread-groups=["i1"],times="1",original-location="next_best_assignment.hpp:129"}
--> R (stepIn-41): {"type":"response","request_seq":41,"success":true,"command":"stepIn","body":{},"seq":3265}

@aakash0641
Copy link
Author

@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 this issue and help.

@sean-mcmanus
Copy link
Contributor

@sean-mcmanus sean-mcmanus reopened this Feb 8, 2022
@aakash0641
Copy link
Author

aakash0641 commented Feb 13, 2022

@aakash0641 Is this issue fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.8.4 ?

@sean-mcmanus Apologies for delay in reply. I was not well. The issue is not fixed yet with 1.8.4 version of C/C++ extension. I am attaching couple of snaps below, which has snapshot of debug console, and installation evidence. 1st snap shows debug console. In the 2nd snap which shows the code, on stepping into function call "constrainedMatching" in line 53, the debug goes into infinite loop, which can be seen in top-right side action box, which shows a pause button in blue color. The 3rd snap shows 1.8.4 version installed.
Screenshot from 2022-02-13 16-57-05
Screenshot from 2022-02-13 16-57-12
Screenshot from 2022-02-13 17-03-38

@aakash0641
Copy link
Author

aakash0641 commented Feb 13, 2022

@sean-mcmanus @WardenGnaw Please let me know in case any more information is needed. I can do a screen-sharing session if that helps in easing the understanding and fixing of bug.

@WardenGnaw
Copy link
Member

@aakash0641 Can you please provide the logs in text format instead of images?

Thank you.

@sean-mcmanus sean-mcmanus added regression A bug that didn't exist in a previous release bug more info needed The issue report is not actionable in its current state and removed duplicate labels Feb 14, 2022
@aakash0641
Copy link
Author

aakash0641 commented Feb 15, 2022

@aakash0641 Can you please provide the logs in text format instead of images?

Thank you.

@WardenGnaw @sean-mcmanus Sure, please find attached a text file having log of debug console. You might have already understood but still I wish to highlight that I had placed a breakpoint within the problematic function, but on pressing either of F11/F10/F5 keys, the debugger does not stop at the inside-breakpoint and it looks like an infinite loop is running (attaching a supporting snap for this too)
8776_debug_console_output.txt
Screenshot from 2022-02-15 12-22-47

@sean-mcmanus sean-mcmanus removed the more info needed The issue report is not actionable in its current state label Feb 15, 2022
@WardenGnaw
Copy link
Member

From the logs, it seems like we are waiting for GDB to complete the step-in request.

Instead of stepping into constrainedMatching from solve, can you do the following?

  1. Stop at solve before constrainedMatching is called.
  2. Set a breakpoint in constrainedMatching the first line, e.g. 136
  3. Hit F5 to continue to that breakpoint

Let me know if you can hit the breakpoint in this case.

@aakash0641
Copy link
Author

aakash0641 commented Feb 17, 2022

From the logs, it seems like we are waiting for GDB to complete the step-in request.

Instead of stepping into constrainedMatching from solve, can you do the following?

  1. Stop at solve before constrainedMatching is called.
  2. Set a breakpoint in constrainedMatching the first line, e.g. 136
  3. Hit F5 to continue to that breakpoint

Let me know if you can hit the breakpoint in this case.

@WardenGnaw This is exactly what I have done multiple times but unsuccessful to hit the breakpoint set in 1st line of constrainedMatching. I can even show you via a screen-sharing session if you want. On hitting F5 (or even F10, F11) the debugging goes into like an infinte loop, despite a breakpoint present in the very next line within the called function constrainedMatching.

@WardenGnaw
Copy link
Member

@aakash0641 I am able to reproduce the issue with step-in. However, this is a GDB issue since it occurs without involving VS Code and the C/C++ Extension.
You can report this at https://sourceware.org/bugzilla/

Repro steps:

  1. Check out https://github.com/whoenig/libMultiRobotPlanning
  2. Install dependencies (see InstallPackagesUbuntu as an example.
  3. Add -g to CMAKE_CXX_FLAGS in CMakeLists.txt
  4. Build as described in README
  5. Debug with just GDB
    1. gdb ecbs_ta
    2. break next_best_assignment.hpp:53
    3. r -i ../benchmark/8x8_obst12/map_8by8_obst12_agents1_ex0.yaml -o ../ofile_1.yaml
    4. continue
    5. step

It will hang after the step call.
image

@WardenGnaw WardenGnaw removed bug regression A bug that didn't exist in a previous release labels Feb 17, 2022
@aakash0641
Copy link
Author

@aakash0641 I am able to reproduce the issue with step-in. However, this is a GDB issue since it occurs without involving VS Code and the C/C++ Extension. You can report this at https://sourceware.org/bugzilla/

Repro steps:

  1. Check out https://github.com/whoenig/libMultiRobotPlanning

  2. Install dependencies (see InstallPackagesUbuntu as an example.

  3. Add -g to CMAKE_CXX_FLAGS in CMakeLists.txt

  4. Build as described in README

  5. Debug with just GDB

    1. gdb ecbs_ta
    2. break next_best_assignment.hpp:53
    3. r -i ../benchmark/8x8_obst12/map_8by8_obst12_agents1_ex0.yaml -o ../ofile_1.yaml
    4. continue
    5. step

It will hang after the step call. image

@WardenGnaw Thanks for this information. I wish to ask whether there is an alternative to GDB that can be used as a debugger with VSCode and C/C++ Extension ? Also, how to use it ? Meanwhile, I will file the bug in the suggested portal.

@github-actions
Copy link

This issue has been closed automatically because it's labeled as 'external'.

@WardenGnaw
Copy link
Member

You can try building with clang and building lldb-mi on linux, but that is a bit more complicated.

I did notice that you were using GDB version 9.2.

You could try upgrading the version of GDB and see if newer version is experiencing this problem.

@aakash0641
Copy link
Author

Yes, I upgraded to GDB version 11.2 and this resolved the problem. Thank you so much @WardenGnaw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants