{"record":{"id":"409c249aecadcf1f","repo":"swc-project/swc","slug":"failed-to-convert-pointer-size-to-calculate-msg","errorCode":null,"errorMessage":"Failed to convert pointer size to calculate: {msg}","messagePattern":"Failed to convert pointer size to calculate: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_runner/src/transform_executor.rs","lineNumber":91,"sourceCode":"        self.instance.cleanup()?;\n\n        // Construct serialized struct from raw bytes.\n        // Since we have finished transformation, it's safe to fetch the data from\n        // Arc<Mutex<T>>\n        drop(self.instance);\n        let transformed_result = Arc::try_unwrap(self.transform_result)\n            .map_err(|_| {\n                anyhow!(\"Failed to unwrap Arc: other references to transform_result exist\")\n            })?\n            .into_inner();\n        let ret = PluginSerializedBytes::from_bytes(transformed_result);\n\n        let ret = if returned_ptr_result == 0 {\n            Ok(ret)\n        } else {\n            let err: PluginError = ret.deserialize()?.into_inner();\n            match err {\n                PluginError::SizeInteropFailure(msg) => Err(anyhow!(\n                    \"Failed to convert pointer size to calculate: {msg}\"\n                )),\n                PluginError::Deserialize(msg) | PluginError::Serialize(msg) => {\n                    Err(anyhow!(\"{msg}\"))\n                }\n                _ => Err(anyhow!(\n                    \"Unexpected error occurred while running plugin transform\"\n                )),\n            }\n        };\n\n        ret\n    }\n\n    /**\n     * Check compile-time version of AST schema between the plugin and\n     * the host. Returns true if it's compatible, false otherwise.\n     *","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_plugin_runner/src/transform_executor.rs#L73-L109","documentation":"The plugin transform returned a nonzero result flag, and the deserialized PluginError is SizeInteropFailure: the plugin-side failed to convert a pointer/size pair during memory interop (u32/u64 conversions around guest memory offsets). The {msg} is the plugin's own description of which conversion failed.","triggerScenarios":"Host and plugin disagree on pointer/size width or the serialized AST payload exceeds size limits during write_into_memory_view-style interop; commonly a symptom of the plugin being built against a different swc_core than the host, or a plugin bug in its memory handling.","commonSituations":"Rebuilding a plugin with a newer swc_core than the embedding host, very large ASTs overflowing guest memory allocations, or hand-rolled plugins that misuse the byte buffer APIs.","solutions":["Align the plugin's swc_core version with the host's swc_core version exactly (major.minor at minimum) and rebuild the .wasm","If it persists, test with a smaller input file to rule out guest memory limits on huge ASTs","Read {msg} - it usually names the exact conversion (e.g. TryFromIntError) and points to the offending side"],"exampleFix":"# plugin's Cargo.toml before\nswc_core = { version = \"9\", features = [...] }\n\n# after - match the host's swc_core\nswc_core = { version = \"10\", features = [...] }\n# then: cargo build --target wasm32-wasi --release","handlingStrategy":"try-catch","validationCode":"// Rust: verify host/plugin swc_core alignment in CI before shipping\n// (parse both versions and compare major.minor)\nfn versions_compatible(host: &str, plugin: &str) -> bool {\n    let mk = |s: &str| s.split('.').take(2).collect::<Vec<_>>();\n    mk(host) == mk(plugin)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Failed to convert pointer size\") => {\n        eprintln!(\"plugin/host interop mismatch - rebuild plugin against swc_core {host_version}\");\n        return Err(e);\n    }\n    other => other,\n}","preventionTips":["Build plugins and host from the same swc_core release; verify in CI","Smoke-test each plugin with a real transform after any dependency bump","Keep very large inputs out of untested paths; add a size-canary test for big ASTs"],"tags":["swc","plugins","wasm","memory-interop","version-mismatch"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}