vitest: Segmentation fault when a breakpoint is attached in VS Code
Describe the bug
When running in VS Code with the recommended launch script from https://vitest.dev/guide/debugging.html, Vitest will error out with a 139 / Segmentation Fault if and only if a breakpoint is attached anywhere in the test file.
josh@LAPTOP-B0MQCQ9I:~/repos/repros$ cd /home/josh/repos/repros ; /usr/bin/env 'NODE_OPTIONS=--require /home/josh/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/extensions/ms-vscode.js-debug/src/bootloader.bundle.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.29903-9.sock","deferredMode":false,"waitForDebugger":"","execPath":"/usr/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","mandatePortTracking":true,"fileCallback":"/tmp/node-debug-callback-6863962514e5d6e5"}' /usr/bin/node ./node_modules/vitest/vitest.mjs run src/index.test.js
Debugger attached.
RUN /home/josh/repos/repros
Segmentation fault
This seems unrelated to the other 2-3 segfault issues.
Reproduction
https://github.com/JoshuaKGoldberg/repros/tree/vitest-segmentation-fault
System Info
System:
OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Memory: 12.01 GB / 24.94 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.13.0 - /usr/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.0 - /usr/bin/npm
npmPackages:
vitest: ^0.4.1 => 0.4.1
Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 21 (9 by maintainers)
Commits related to this issue
- docs(useWebWorker): fix import path, close #795 (#814) — committed to chaii3/vitest by phaust 3 years ago
I’ve managed to get to here before it segfaults: https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/execute.ts#L19
Here is the call stack, right up to the point before it segfaults:
From cachedRequest directRequest gets called and
vm.runInThisContext
runs triggering the segfault.It’s this:
https://user-images.githubusercontent.com/936006/155585500-f5eac2dd-3ca5-4057-b676-313c5f745243.mp4
which I’m guessing is related to https://github.com/nodejs/node/issues/37648 why it only happens on debugger I don’t know.
Location in code
https://github.com/vitest-dev/vitest/blob/main/packages/vite-node/src/client.ts#L121-L124
System Details
Segfault output
CC @connor4312
Thanks for the ping. Unfortunately not a whole lot we can do on the VS Code side for cases like this.
I noticed that my “Node.js” version in vscode was the same as that of @TrickyPi, but the version I am running in command line was v16.14.0.
I decided to downgrade my version of node (with nvm) to v14.16.0 (to match vscode’s version) and the error stopped appearing. I started trying different versions of node, from 14.16 and up, and once I hit v16.8.0, the segmentation fault starts to occur.
Here is the complete list of versions I tried: Versions that work: v14.19.0, v15.12.0, v16.0.0, v16.3.0, v16.5.0, v16.7.0 Versions that resulted in segfault: v16.8.0, v16.13.0, v16.14.0, v17.5.0