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

debugger quit when setting break point or switching to another thread on ubuntu 22.04 (WSL2) #9253

Closed
pohhsu opened this issue Apr 29, 2022 · 4 comments
Labels

Comments

@pohhsu
Copy link

pohhsu commented Apr 29, 2022

Environment

  • OS and version: Windows 11 WSL2 Ubuntu 22.04
  • VS Code:
    Version: 1.66.2 (user setup)
    Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
    Date: 2022-04-11T07:46:01.075Z
    Electron: 17.2.0
    Chromium: 98.0.4758.109
    Node.js: 16.13.0
    V8: 9.8.177.11-electron.0
    OS: Windows_NT x64 10.0.22000
  • C/C++ extension:
    C/C++ v1.9.8
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version:
    GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
    Copyright (C) 2022 Free Software Foundation, Inc.

Bug Summary and Steps to Reproduce

Bug Summary:
VC code debugger quits immediately after start debugging with:
Aborted (core dumped)
[1] + Aborted (core dumped) "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-ns2vuk2i.3xq" 1>"/tmp/Microsoft-MIEngine-Out-br5vdh4k.oln"

Steps to reproduce:

Install Ubuntu22.04 on WSL2 on Windows 11
build main.cpp (see attached repro.zip) via
g++ -g -O0 main.cpp

set breakpoint on line 8

void threadFunction()
{
std::this_thread::sleep_for(50000ms); <--- here
}

start debugging, and it will core dump.

Note, without setting breakpoint, if you start debugging, and hit pause, then switch the thread to the 2nd thread, it will also quit.

note that using console gdb it is fine
repro.zip
.

Debugger Configurations

{
    // 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",
//            "logging": { "engineLogging": true, "trace": true, "traceResponse": true },
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "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
                }
            ]
        }        
    ]
}

Debugger Logs

the log is attached as repro.log below

Other Extensions

no other extensions were enabled.

Additional Information

repro.zip
repro.log

@WardenGnaw
Copy link
Member

This seems to be an error with gdb under mi mode.

From the logs:

/build/gdb-wIRHdd/gdb-12.0.90/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.\nA problem internal to GDB has been detected, further debugging may prove unreliable.
This is a bug, please report it."
For instructions, see: https://www.gnu.org/software/gdb/bugs/

@AlbertDM
Copy link

AlbertDM commented May 4, 2022

I can replicate the same issue using GDB in VSCode in Ubuntu 22.04 natively installed. Before I was running same project in Ubuntu 20.04 and this was not happening.

When a breakpoint is set in the main thread (Thread 1), everything runs flawlessly but when the breakpoint happens to be in a different thread I get the same error as OP:

/build/gdb-wIRHdd/gdb-12.0.90/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

@AlbertDM
Copy link

AlbertDM commented May 4, 2022

I have been able so solve it, and now I can debug threaded applications with GDB 12.1 and Ubuntu 22.04:

https://www.sourceware.org/gdb/

  • May 1st, 2022: GDB 12.1 Released!
    • GDB version 12.1 per default can work with threaded symbols.
  1. Download: http://ftp.gnu.org/gnu/gdb/gdb-12.1.tar.gz
  2. Run sudo apt-get install libgmp-dev
  3. tar -xvzf gdb-12.1.tar.gz
  4. cd gdb-12.1
  5. ./configure
  6. make
  7. sudo make install
  8. Edit run_gdb in your project so it uses your local gdb: sudo /usr/local/bin/gdb "$@"
  9. Make sure gdb is in sudoers:
    • sudo nvim /etc/sudoers
    • <user> ALL=NOPASSWD:/usr/local/bin/gdb

@pohhsu pohhsu closed this as completed May 6, 2022
@richardh538
Copy link

I have been able so solve it, and now I can debug threaded applications with GDB 12.1 and Ubuntu 22.04:

Excellent! Thank you very much, this solved my debug issues as well.

I downloaded the pre-built package from launchpad

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants