Skip to content

Segfaults with dynamic imports and mocha #27492

Closed
@demurgos

Description

@demurgos
  • Version: 12.1.0
  • Platform: Linux 5.0.9 64-bit
  • Subsystem: modules

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:

node --experimental-modules --es-module-specifier-resolution=node node_modules/mocha/bin/_mocha build/test/test.esm.js --delay --async --no-config --no-package --no-opts --diff --extension js --reporter spec --slow 75 --timeout 2000 --ui bdd

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.experimentalIssues and PRs related to experimental features.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions