Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using plugins: thread '<unnamed>' panicked at 'assertion failed: prev.start > max' #7304

Closed
await-ovo opened this issue Apr 20, 2023 · 4 comments
Labels
Milestone

Comments

@await-ovo
Copy link

await-ovo commented Apr 20, 2023

Describe the bug

Steps to reproduce:

  1. git clone https://github.com/await-ovo/reproduce-swc-plugins-crash-issue
  2. cd reproduce-swc-plugins-crash-issue
  3. pnpm i
  4. RUST_BACKTRACE=1 node ./index.mjs:

Then you can see the following error:

$ RUST_BACKTRACE=1 node ./index.mjs
thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:224:9
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
/Users/await-ovo/Documents/test/reproduce-swc-plugins-crash-issue/node_modules/.pnpm/@swc+core@1.3.52/node_modules/@swc/core/index.js:241
            return bindings.transformSync(isModule ? JSON.stringify(src) : src, isModule, toBuffer(newOptions));
                            ^

Error: failed to handle: assertion failed: prev.start > max

Stack backtrace:
   0: _napi_register_module_v1
   1: _wasmer_vm_imported_memory32_atomic_notify
   2: <unknown>
   3: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
   4: __ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
   5: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
   6: __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
    at Compiler.transformSync (/Users/await-ovo/Documents/test/reproduce-swc-plugins-crash-issue/node_modules/.pnpm/@swc+core@1.3.52/node_modules/@swc/core/index.js:241:29)
    at transformSync (/Users/await-ovo/Documents/test/reproduce-swc-plugins-crash-issue/node_modules/.pnpm/@swc+core@1.3.52/node_modules/@swc/core/index.js:348:21)
    at file:///Users/await-ovo/Documents/test/reproduce-swc-plugins-crash-issue/index.mjs:5:16
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12) {
  code: 'GenericFailure'
}
  1. Re-execute node ./index.mjs: you can see that transform is work as expected:
$ node ./index.mjs 
transform output: import A from "lodash/A";
console.log(A);

Delete the .swc directory, and then execute node ./index.mjs. The error in step 2 will appear again.

Input code

import { transformSync } from "@swc/core";

const code = `import { A } from 'lodash';console.log(A);`;

const result = transformSync(code, {
  filename: "example.js",
  swcrc: false,
  configFile: false,
  jsc: {
    parser: {
      syntax: "ecmascript",
      jsx: false,
    },
    experimental: {
      plugins: [
        [
          "@swc/plugin-transform-imports",
          {
            lodash: {
              transform: "lodash/{{member}}",
            },
          },
        ],
        [
          "@swc/plugin-noop",
          {}
        ],
      ],
    },
  },
});

console.log(`transform output:`, result.code)

Config

no

Playground link

No response

Expected behavior

transformSync works as expected

Actual behavior

The error is reported as above.

Version

1.3.52

Additional context

It looks like this error only occurs if you set up multiple plugins, if you comment out the @swc/plugin-noop in index.mjs, node . /index.mjs will work fine.

I'm trying to develop some swc plugins, individual plugins are working fine, but as soon as I set all the plugins together to experiment.plugins, I get the error reported above, I'm not sure if there is something wrong with the way I'm using it, or if this is a stupid problem, if so, please forgive me, thanks a lot ~

env info:

  System:
    OS: macOS 11.7.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 42.06 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Managers:
    Cargo: 1.68.2 - ~/.cargo/bin/cargo
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Clang: 13.0.0 - /usr/bin/clang
  Languages:
    Rust: 1.68.2 - /Users/await-ovo/.cargo/bin/rustc
@kdy1
Copy link
Member

kdy1 commented Apr 20, 2023

Filed wasmerio/wasmer#3793

jbedard added a commit to aspect-build/rules_swc that referenced this issue May 2, 2023
jbedard added a commit to aspect-build/rules_swc that referenced this issue May 2, 2023
alexeagle pushed a commit to aspect-build/rules_swc that referenced this issue May 2, 2023
@tajo
Copy link

tajo commented May 30, 2023

Also experiencing this issue when trying to use more than one swc plugin. Is there some specific version of swc_core crate & @swc/core that works with plugins? We've been using this setup https://github.com/swc-project/plugins for authoring plugins.

Also, using .wasm files directly if it makes any difference:

import { transform } from '@swc/core';

await transform(code, {
  sourceMaps: true,
  isModule: true,
  filename: id,
  jsc: {
    experimental: {
      plugins: [
        [join(_dirname, 'swc_plugin_emotion.wasm'), {}],
        [join(_dirname, 'swc_plugin_fusion_asseturl.wasm'), {}],
      ],
    }
  }
});

@kwonoj
Copy link
Member

kwonoj commented Jul 26, 2023

Upstream issue is resolved, so I think this is ok now. If it still happens, please file with repro with the latest versions.

@kwonoj kwonoj closed this as completed Jul 26, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.72 Jul 28, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 28, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

5 participants