Skip to content

When debugging multiple inferiors with gdb, if one inferior exits the full debug session stops #13893

Open
microsoft/MIEngine
#1627

Description

Environment

  • OS and version: Arch Linux with gdb 16.3
  • VS Code: 1.103.1
  • C/C++ extension: 1.26.3
  • OS and version of remote machine (if applicable): n/a
  • GDB / LLDB version: 16.3

Bug Summary and Steps to Reproduce

Bug Summary:

When debugging multiple inferiors in gdb, if one inferior exits the vscode debug session ends.

Steps to reproduce:

  1. git clone this repo: https://github.com/lostgoat/multiinferior-repro
  2. Set a breakpoint on the "parent exiting" line
  3. Start the "(gdb) Launch" debug task

When running gdb with the same configuration via commandline everything works correctly. Execution pauses after the child exits, and then one can use inferior <id> to switch back to the parent and keep debugging.

Debugger Configurations

{
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "preLaunchTask": "build test app",
            "request": "launch",
            "program": "${workspaceFolder}/test.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Keep both sides of fork",
                    "text": "set detach-on-fork off"
                },
                {
                    "description": "Allow multiple inferiors to run",
                    "text": "set schedule-multiple on"
                }
            ],
            "logging": { "engineLogging": true, "trace": true, "traceResponse": true }
        },

Debugger Logs

Output window:

Starting test
parent running 
waiting for child: 965664
parent waitpid returned: 0 - 0
child started
child looping: 0
child looping: 1
child looping: 2
child looping: 3
parent waitpid returned: 0 - 0
child looping: 4
child looping: 5
child looping: 6
child looping: 7
parent waitpid returned: 0 - 0
child looping: 8
child looping: 9
child exiting

Other Extensions

No response

Additional Information

No response

Activity

  1. lostgoat commented on Sep 2, 2025

    @lostgoat
    Author

    Including just a snippet of the trace debugger logs since it didn't let me paste the whole thing in the issue template:

    [Thread debugging using libthread_db enabled]
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (448) ->~\"Using host libthread_db library \\\"/usr/lib/libthread_db.so.1\\\".\\n\"\n"},"seq":472}
    1: (448) ->~"Using host libthread_db library \"/usr/lib/libthread_db.so.1\".\n"
    --> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"Using host libthread_db library \"/usr/lib/libthread_db.so.1\".\n"},"seq":475}
    Using host libthread_db library "/usr/lib/libthread_db.so.1".
    <--   C (threads-10): {"command":"threads","type":"request","seq":10}
    --> R (threads-10): {"type":"response","request_seq":10,"success":true,"command":"threads","body":{"threads":[{"id":965952,"name":"test.out [965952]"},{"id":965957,"name":"test.out [965957]"}]},"seq":478}
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5449) ->~\"[Inferior 2 (process 965957) exited normally]\\n\"\n"},"seq":480}
    1: (5449) ->~"[Inferior 2 (process 965957) exited normally]\n"
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5450) ->=thread-exited,id=\"2\",group-id=\"i2\"\n"},"seq":482}
    1: (5450) ->=thread-exited,id="2",group-id="i2"
    --> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"[Inferior 2 (process 965957) exited normally]\n"},"seq":483}
    [Inferior 2 (process 965957) exited normally]
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5450) ->=thread-group-exited,id=\"i2\",exit-code=\"0\"\n"},"seq":486}
    1: (5450) ->=thread-group-exited,id="i2",exit-code="0"
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5450) ->*stopped,reason=\"exited-normally\"\n"},"seq":488}
    1: (5450) ->*stopped,reason="exited-normally"
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5451) Send Event AD7ThreadDestroyEvent\n"},"seq":490}
    1: (5451) Send Event AD7ThreadDestroyEvent
    --> E (thread): {"type":"event","event":"thread","body":{"reason":"exited","threadId":965957},"seq":492}
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5452) <--gdb-exit\n"},"seq":494}
    1: (5452) <--gdb-exit
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5452) ->^exit\n"},"seq":496}
    1: (5452) ->^exit
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5453) ->=thread-exited,id=\"1\",group-id=\"i1\"\n"},"seq":498}
    1: (5453) ->=thread-exited,id="1",group-id="i1"
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5453) ->=thread-group-exited,id=\"i1\"\n"},"seq":500}
    1: (5453) ->=thread-group-exited,id="i1"
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5454) Send Event AD7ProgramDestroyEvent\n"},"seq":502}
    1: (5454) Send Event AD7ProgramDestroyEvent
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"The program '/home/andres/git/multiinferior-repro/test.out' has exited with code 0 (0x00000000).\r\n\n"},"seq":504}
    The program '/home/andres/git/multiinferior-repro/test.out' has exited with code 0 (0x00000000).
    --> E (exited): {"type":"event","event":"exited","body":{"exitCode":0},"seq":506}
    --> E (terminated): {"type":"event","event":"terminated","body":{},"seq":508}
    --> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"17.12.21003.1","VS.Diagnostics.Debugger.HostVersion":"17.12.21003.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":0}},"seq":510}
    <--   C (disconnect-11): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":11}
    --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5459) Send Event AD7ThreadDestroyEvent\n"},"seq":513}
    1: (5459) Send Event AD7ThreadDestroyEvent
    --> R (disconnect-11): {"type":"response","request_seq":11,"success":true,"command":"disconnect","body":{},"seq":515}
    

    And attaching the full output as a file:

    debug.txt

  2. github-actions commented on Sep 3, 2025

    @github-actions

    Thank you for reporting this issue. We’ll let you know if we need more information to investigate it. Additionally, if you're working with GDB/LLDB, please note that the code is open source at https://github.com/microsoft/MIEngine/wiki/Contributing-Code . Your contributions are always welcome and appreciated.

  3. drok commented on Oct 9, 2026

    @drok

    Dear microsoft, you received the help you wanted, a ready made patch complete with test case. Any chance of acting on this bug?

    At the very least remove your help-wanted tag.

  4. sean-mcmanus commented on Oct 9, 2026

    @sean-mcmanus
    Contributor

    Radu Hociung (@drok) I believe the PR should be re-opened.

  5. drok commented on Oct 13, 2026

    @drok

    Sean McManus (@sean-mcmanus) I concur.

    Actually, by "concur" I mean "recommend you do the work and take responsibility for it"

    By "recommend" I mean "permit"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdebuggerhelp wantedCan be fixed in the public (open source) repo.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions