swc: Plugin crashes with rkyv LayoutError.
Describe the bug
SWC crashes when trying to invoke a plugin.
versions:
@swc/core
- 1.3.26swc_core
- 0.56.1
backtrace:
❯ SWC_DEBUG=1 RUST_BACKTRACE=full swc --sync demo/src/index.ts
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /Users/k.mironov/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Panic: PanicInfo { payload: Any { .. }, message: Some(failed to invoke plugin: failed to invoke plugin on 'Some("demo/src/index.ts")'
Caused by:
0: failed to invoke `@effector/swc-plugin` as js transform plugin at node_modules/@effector/swc-plugin/target/wasm32-wasi/debug/effector_swc_plugin.wasm
1: RuntimeError: unreachable
at __rust_start_panic (<module>[11103]:0x438b25)
at rust_panic (<module>[11093]:0x438815)
at std::panicking::rust_panic_with_hook::had8ec4151dd4c568 (<module>[11092]:0x4387e4)
at std::panicking::begin_panic_handler::{{closure}}::h2ac729f2457e9805 (<module>[11080]:0x437aa2)
at std::sys_common::backtrace::__rust_end_short_backtrace::hfe2c5b74343c0cd6 (<module>[11079]:0x4379cc)
at rust_begin_unwind (<module>[11087]:0x438060)
at core::panicking::panic_fmt::hd7053c514eb59581 (<module>[11226]:0x4461cd)
at core::result::unwrap_failed::h7e5c994e75ab37e8 (<module>[11275]:0x44ca56)
at core::result::Result<T,E>::unwrap::h2356290abca8ee50 (<module>[10820]:0x4287c8)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::h315b3a8965376629 (<module>[5344]:0x2b5bfa)
at rkyv::impls::alloc::vec::<impl rkyv::Deserialize<alloc::vec::Vec<T>,D> for rkyv::vec::ArchivedVec<<T as rkyv::Archive>::Archived>>::deserialize::h04d1ec3ea3e970d8 (<module>[222]:0x13be0)
at swc_ecma_ast::module_decl::_::<impl rkyv::Deserialize<swc_ecma_ast::module_decl::ImportDecl,__D> for <swc_ecma_ast::module_decl::ImportDecl as rkyv::Archive>::Archived>::deserialize::h185c61ae65c5c0b5 (<module>[5304]:0x2a51dd)
at swc_ecma_ast::module_decl::_::<impl rkyv::Deserialize<swc_ecma_ast::module_decl::ModuleDecl,__D> for <swc_ecma_ast::module_decl::ModuleDecl as rkyv::Archive>::Archived>::deserialize::h952789b151c9a970 (<module>[5305]:0x2a597c)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::ModuleItem,__D> for <swc_ecma_ast::module::ModuleItem as rkyv::Archive>::Archived>::deserialize::h88d8e5b435c0c70e (<module>[5724]:0x2cf7ff)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::h006528daf2248e8c (<module>[5738]:0x2d413c)
at rkyv::impls::alloc::vec::<impl rkyv::Deserialize<alloc::vec::Vec<T>,D> for rkyv::vec::ArchivedVec<<T as rkyv::Archive>::Archived>>::deserialize::h380c70590928e990 (<module>[227]:0x147f2)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::Module,__D> for <swc_ecma_ast::module::Module as rkyv::Archive>::Archived>::deserialize::h86f80a54809dc175 (<module>[5721]:0x2ce741)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::Program,__D> for <swc_ecma_ast::module::Program as rkyv::Archive>::Archived>::deserialize::he0c1e07561c3b81a (<module>[5723]:0x2cefcf)
at swc_common::plugin::serialized::PluginSerializedBytes::deserialize::hd942b90ece579bfb (<module>[4013]:0x1ad338)
at swc_common::plugin::serialized::deserialize_from_ptr::h3a43eb3fbcea6d36 (<module>[4012]:0x1ac686)
at __transform_plugin_process_impl (<module>[6596]:0x31c0a3)
at __transform_plugin_process_impl.command_export (<module>[11393]:0x45418b)
2: unreachable
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_raise_trap
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _napi_register_module_v1
7: _napi_register_module_v1
8: <unknown>
9: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
10: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
11: __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE), location: Location { file: "/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.241.5/src/plugin.rs", line: 228, col: 14 }, can_unwind: true }
Backtrace: 0: <unknown>
1: <unknown>
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _wasmer_vm_raise_trap
7: _wasmer_vm_raise_trap
8: _napi_register_module_v1
9: _napi_register_module_v1
10: _napi_register_module_v1
11: _napi_register_module_v1
12: <unknown>
13: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
14: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
15: __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("demo/src/index.ts")'
Caused by:
0: failed to invoke `@effector/swc-plugin` as js transform plugin at node_modules/@effector/swc-plugin/target/wasm32-wasi/debug/effector_swc_plugin.wasm
1: RuntimeError: unreachable
at __rust_start_panic (<module>[11103]:0x438b25)
at rust_panic (<module>[11093]:0x438815)
at std::panicking::rust_panic_with_hook::had8ec4151dd4c568 (<module>[11092]:0x4387e4)
at std::panicking::begin_panic_handler::{{closure}}::h2ac729f2457e9805 (<module>[11080]:0x437aa2)
at std::sys_common::backtrace::__rust_end_short_backtrace::hfe2c5b74343c0cd6 (<module>[11079]:0x4379cc)
at rust_begin_unwind (<module>[11087]:0x438060)
at core::panicking::panic_fmt::hd7053c514eb59581 (<module>[11226]:0x4461cd)
at core::result::unwrap_failed::h7e5c994e75ab37e8 (<module>[11275]:0x44ca56)
at core::result::Result<T,E>::unwrap::h2356290abca8ee50 (<module>[10820]:0x4287c8)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::h315b3a8965376629 (<module>[5344]:0x2b5bfa)
at rkyv::impls::alloc::vec::<impl rkyv::Deserialize<alloc::vec::Vec<T>,D> for rkyv::vec::ArchivedVec<<T as rkyv::Archive>::Archived>>::deserialize::h04d1ec3ea3e970d8 (<module>[222]:0x13be0)
at swc_ecma_ast::module_decl::_::<impl rkyv::Deserialize<swc_ecma_ast::module_decl::ImportDecl,__D> for <swc_ecma_ast::module_decl::ImportDecl as rkyv::Archive>::Archived>::deserialize::h185c61ae65c5c0b5 (<module>[5304]:0x2a51dd)
at swc_ecma_ast::module_decl::_::<impl rkyv::Deserialize<swc_ecma_ast::module_decl::ModuleDecl,__D> for <swc_ecma_ast::module_decl::ModuleDecl as rkyv::Archive>::Archived>::deserialize::h952789b151c9a970 (<module>[5305]:0x2a597c)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::ModuleItem,__D> for <swc_ecma_ast::module::ModuleItem as rkyv::Archive>::Archived>::deserialize::h88d8e5b435c0c70e (<module>[5724]:0x2cf7ff)
at rkyv::impls::core::<impl rkyv::DeserializeUnsized<[U],D> for [T]>::deserialize_unsized::h006528daf2248e8c (<module>[5738]:0x2d413c)
at rkyv::impls::alloc::vec::<impl rkyv::Deserialize<alloc::vec::Vec<T>,D> for rkyv::vec::ArchivedVec<<T as rkyv::Archive>::Archived>>::deserialize::h380c70590928e990 (<module>[227]:0x147f2)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::Module,__D> for <swc_ecma_ast::module::Module as rkyv::Archive>::Archived>::deserialize::h86f80a54809dc175 (<module>[5721]:0x2ce741)
at swc_ecma_ast::module::_::<impl rkyv::Deserialize<swc_ecma_ast::module::Program,__D> for <swc_ecma_ast::module::Program as rkyv::Archive>::Archived>::deserialize::he0c1e07561c3b81a (<module>[5723]:0x2cefcf)
at swc_common::plugin::serialized::PluginSerializedBytes::deserialize::hd942b90ece579bfb (<module>[4013]:0x1ad338)
at swc_common::plugin::serialized::deserialize_from_ptr::h3a43eb3fbcea6d36 (<module>[4012]:0x1ac686)
at __transform_plugin_process_impl (<module>[6596]:0x31c0a3)
at __transform_plugin_process_impl.command_export (<module>[11393]:0x45418b)
2: unreachable
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_raise_trap
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _napi_register_module_v1
7: _napi_register_module_v1
8: <unknown>
9: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
10: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
11: __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_raise_trap
2: <unknown>
3: __ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
4: __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
5: __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
Error: Failed to compile 1 file with swc.
at Object.assertCompilationResult (/Users/k.mironov/WebstormProjects/swc-plugin/node_modules/.pnpm/@swc+cli@0.1.59_@swc+core@1.3.26/node_modules/@swc/cli/lib/swc/util.js:123:15)
at files (/Users/k.mironov/WebstormProjects/swc-plugin/node_modules/.pnpm/@swc+cli@0.1.59_@swc+core@1.3.26/node_modules/@swc/cli/lib/swc/file.js:173:18)
at async _default (/Users/k.mironov/WebstormProjects/swc-plugin/node_modules/.pnpm/@swc+cli@0.1.59_@swc+core@1.3.26/node_modules/@swc/cli/lib/swc/file.js:192:9)
Input code
import {createEvent, createStore} from 'effector';
import {factory} from "./factory";
const increment = createEvent();
console.log(createStore(createEvent()))
console.log(factory(increment));
Config
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"experimental": {
"plugins": [
[
"@effector/swc-plugin",
{
"addLoc": true,
"factories": ["./tests/fixtures/factories/factory"]
}
]
]
}
}
}
Playground link
No response
Expected behavior
Plugin runs.
Actual behavior
Plugin system crashes.
Version
1.3.26
Additional context
https://github.com/effector/swc-plugin
Repository of a plugin, you can run cargo build
and pnpm i
to reproduce it there.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 8
- Comments: 20 (15 by maintainers)
Commits related to this issue
- ci: add rust-toolchain.toml - see https://github.com/swc-project/swc/issues/6807 — committed to VKCOM/swc-plugin-transform-remove-imports by SevereCloud a year ago
- ci: add rust-toolchain.toml (#19) - see https://github.com/swc-project/swc/issues/6807 — committed to VKCOM/swc-plugin-transform-remove-imports by SevereCloud a year ago
- build(cargo): Update `rustc` to `nightly-2023-03-28` (#7154) **Description:** This PR also updates `rkyv` to `=0.7.40`. **Related issue:** - Closes https://github.com/swc-project/swc/issues... — committed to swc-project/swc by kdy1 a year ago
- build(cargo): Update `rustc` to `nightly-2023-03-20` (#7170) **Description:** This PR also updates `rkyv` to `=0.7.40`. **Related issue:** - Closes https://github.com/swc-project/swc/issues... — committed to swc-project/swc by kdy1 a year ago
Tentatively assigned myself to try repro. (Well, if I have some time…)