-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Segfaults with dynamic imports and mocha #27492
Copy link
Copy link
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.experimentalIssues and PRs related to experimental features.Issues and PRs related to experimental features.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.experimentalIssues and PRs related to experimental features.Issues and PRs related to experimental features.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
I am testing the new ESM implementation on one of my projects. I am able to consistently get segfaults when using experimental modules and dynamic imports with mocha unit tests.
I extracted a reproducible example to demurgos/node-esm-sigsegv. I am working on reducing the example to be minimal.
The README.md has more details, here is a summary:
You can clone the repo, install the dependencies and run the following command:
The segfault occurs while evaluating the function in test.esm.js.
This function sequentially dynamically imports ESM spec files.
When importing a single file, the execution succeeds.
When importing 2 or 3 files, the execution segfaults 25% of the time.
When importing more files, the execution always segfaults.
I don't know the exact cause of the segfault yet. I am working on isolating it to a minimal example.
It is worth noting that Mocha injects global variables (which may interact badly with ES modules). It may also be a mocha bug, at the moment I am suspecting an ESM issue because it is a C++ crash (and not a JS exception).