swc: `RuntimeError: out of bounds memory access` when using plugin on a large nested AST

Describe the bug

When a large nested file being loaded to swc with plugin, the plugin_runner will crash. When same file being loaded to swc without plugin, no error is thrown.

Input code

export result = {
      output: outputBuilder()
        .addConfig(1)
        .addConfig(2)
        .addConfig(3)
        .addConfig(4)
        .addConfig(5)
        ....
        .addConfig(1500)
        .build(),
    }

Config

{
  "$schema": "https://swc.rs/schema.json",
  "jsc": {
    "experimental": {
      "plugins": [["@swc/plugin-noop", {}]]
    }
  }
}

Playground link (or link to the minimal reproduction)

https://github.com/jzhan-canva/swc-plugin-bug

SWC Info output

No response

Expected behavior

Same a running swc without plugin, that it should run

Actual behavior

Crash image

Version

“@swc/cli”: “^0.5.2”, “@swc/core”: “^1.9.3”, “@swc/plugin-noop”: “^5.0.0”

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

No, I mean it’s failing with rkyv. The example plugin does not visit the program.