Skip to content

segfault when using ESM dynamic import repeatedly in special circumstances #39964

Open
@mkg20001

Description

@mkg20001

Version

v16.8.0

Platform

Linux mkg-razer 5.10.61 #1-NixOS SMP Thu Aug 26 12:51:21 UTC 2021 x86_64 GNU/Linux

Subsystem

ESM modules

What steps will reproduce the bug?

  • Create a package.json with at least "type": "module" set
  • Create a file b.js with the following contents
export default () => {}
  • Open a nodeJS repl and paste the following
async function require (thing) {
  const imported = await import(thing) // "dynamic import"
  return Object.assign(imported.default, imported)
}

require('./b.js')

Wait a few seconds and run require('./b.js') again

How often does it reproduce? Is there a required condition?

Sometimes it doesn't segfault, try running require('./b.js') again a few times, or try something like require('./b.js').then(console.log)

What is the expected behavior?

It should return the module

What do you see instead?

It segfaults

Segmentation fault (Speicherabzug geschrieben)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions