vscode-bash-debug icon indicating copy to clipboard operation
vscode-bash-debug copied to clipboard

Debugger times out while the Bash shell is still going through the initialization

Open dseynhae opened this issue 2 years ago • 1 comments

In addition to the details for issue, please provide us Executables information and Debug output unless you have confidence that they don't help us.

Executables

Version of bash-debug: v0.3.9

Output of following commands (on windows, execute them in Command Prompt or PowerShell):

where bash
C:\Windows\System32\bash.exe
code --version
code --version
1.70.2
e4503b30fc78200f846c62cf8091b76ff5547662
x64
bash -c 'uname -a; for P in bash bashdb cat mkfifo pkill; do echo ---; which -a $P; command $P --version; done'
Linux dseynhae-MOBL1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
---
/usr/bin/bash
/bin/bash
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 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.
---
/bin/bash: bashdb: command not found
---
/usr/bin/cat
/bin/cat
cat (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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.

Written by Torbjorn Granlund and Richard M. Stallman.
---
/usr/bin/mkfifo
/bin/mkfifo
mkfifo (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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.

Written by David MacKenzie.
---
/usr/bin/pkill
/bin/pkill
pkill from procps-ng 3.3.16

Debug output

There is not output, the error window just pops up after 5 seconds. Your launch.json may looks like:

{
  // 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": [
    {
      "type": "bashdb",
      "request": "launch",
      "showDebugOutput": true,
      "trace": true,
      "name": "Bash-Debug (simplest configuration)",
      "program": "${file}"
    }
  ]
}

Details

Debugger doesn't run:

image

I am pretty sure it is an issue with the timeout not being long enough (my bash shell takes about 5 seconds to start up):

  1. If I disable my init scripts, the debugger comes up.
  2. If I instrument my init scripts to produce a heartbeat into a file, I can tail -f this heartbeat. When I start the debugger, the heartbeat shows that we go through the full initialization. But before we reach the end, the error message pops up.
  3. I simplified the .bashrc to a sleep command. 4 seconds and below consistently gets the debugger to work; 5 seconds and above fails, and the error dialog comes up after exactly 5 seconds.

Note: Python used to have the same problem. They resolved it by making the timeout configurable in the launch.json configuration.

dseynhae avatar Aug 25 '22 23:08 dseynhae

For the script I'm debugging right now, I can just disable my initialization. In my .bashrc, I return immediately if the Bash shell is invoked by the VS Code debugging environment:

# Don't run initialization when running in VS Code Debugger
if env | grep -q VSCODE_HANDLES; then
        return 1
fi

I would prefer to be able to increase the "timeout" in my launch.json configuration though...

dseynhae avatar Aug 26 '22 00:08 dseynhae