facebook / facebook/hhvm

[vsdebug] Segfault in running script when VS Code debugger tries to attach

Open
#8,667 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

**Describe the bug**
VS Code debugger cannot attach and debug a script in vsdebug mode if the script is already running (i.e. was started with the `--vsDebugNoWait true` argument). On trying to attach, the script crashes with a segfault

Affects at least versions 4.36.0+, but likely a few before that as well.

**Standalone code, or other way to reproduce the problem**

Write any long-running script:

**file1.hack**
```Hack
<<__EntryPoint>>
function file1_main(): void {
while (true) {
echo "Sleeping...\n";
sleep(2);
}
}
```

**Success case** - run this with `hhvm --mode vsdebug --vsDebugPort 8999 file1.hack`. Script will wait for the debugger to attach. Create an "Attach" config in VS Code and start debugging. Script will start running and output will be visible in the terminal as well as the vscode debug panel. Breakpoints etc. will work as well.

**Failure case** - run this with `hhvm --mode vsdebug --vsDebugPort 8999 --vsDebugNoWait true file1.hack`. Script will start running immediately (as expected). Now go to VS Code and start the same debug config. Script will immediately segfault.

**Error:**
```
Core dumped: Segmentation fault
Stack trace in /tmp/stacktrace.1027.log
Segmentation fault (core dumped)
```

Log file contains:
```
Host: df9d9ce48ea9
ProcessID: 1027
ThreadID: 140412562630400
ThreadPID: 1033
Name: /usr/bin/hhvm
CmdLine: hhvm --mode vsdebug --vsDebugPort 8999 --vsDebugNoWait true file1.hack
Type: Segmentation fault
Runtime: hhvm
Version: 1582567844_825223418
DebuggerCount: 1

# 0 00005581de2fd256
# 1 00005581de5bd5c5
# 2 00007fb46fb91890
# 3 00005581df9dd7bc
# 4 00005581de67da8b
# 5 00005581df9dc90b
# 6 00005581df9f0108
# 7 00005581df9f04ae
# 8 00005581de2d4be2
# 9 00005581de2d4e16
# 10 00007fb46fb866db
# 11 00007fb4691ae88f
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.