{"record":{"id":"81c161b6a036a4a7","repo":"zeroclaw-labs/zeroclaw","slug":"runtime-wasm-memory-limit-mb-of-exceeds-the-4-g","errorCode":null,"errorMessage":"runtime.wasm.memory_limit_mb of {} exceeds the 4 GB safety limit for 32-bit WASM","messagePattern":"runtime\\.wasm\\.memory_limit_mb of (.+?) exceeds the 4 GB safety limit for 32-bit WASM","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/platform/wasm.rs","lineNumber":71,"sourceCode":"    pub fn with_workspace(config: WasmRuntimeConfig, workspace_dir: PathBuf) -> Self {\n        Self {\n            config,\n            workspace_dir: Some(workspace_dir),\n        }\n    }\n\n    /// Check if the WASM runtime feature is available in this build.\n    pub fn is_available() -> bool {\n        cfg!(feature = \"runtime-wasm\")\n    }\n\n    /// Validate the WASM config for common misconfigurations.\n    pub fn validate_config(&self) -> Result<()> {\n        if self.config.memory_limit_mb == 0 {\n            bail!(\"runtime.wasm.memory_limit_mb must be > 0\");\n        }\n        if self.config.memory_limit_mb > 4096 {\n            bail!(\n                \"runtime.wasm.memory_limit_mb of {} exceeds the 4 GB safety limit for 32-bit WASM\",\n                self.config.memory_limit_mb\n            );\n        }\n        if self.config.tools_dir.is_empty() {\n            bail!(\"runtime.wasm.tools_dir cannot be empty\");\n        }\n        // Verify tools directory doesn't escape workspace\n        if self.config.tools_dir.contains(\"..\") {\n            bail!(\"runtime.wasm.tools_dir must not contain '..' path traversal\");\n        }\n        Ok(())\n    }\n\n    /// Resolve the absolute path to the WASM tools directory.\n    pub fn tools_dir(&self, workspace_dir: &Path) -> PathBuf {\n        workspace_dir.join(&self.config.tools_dir)\n    }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/platform/wasm.rs#L53-L89","documentation":"The second WASM config guard: memory_limit_mb above 4096 is rejected because it exceeds the 4 GB address space of 32-bit WASM memories. A limit larger than what a wasm32 module can ever address is either a unit mistake (bits vs bytes, MB vs GB) or a mispaste, so validate_config refuses it rather than silently clamping.","triggerScenarios":"Setting memory_limit_mb = 8192 or 16384 copying native-container habits; entering a byte count (4294967296) instead of megabytes; upgrading configs from systems that expressed limits differently.","commonSituations":"Teams used to 64-bit native runtimes requesting tens of GB; unit confusion between MiB/GB; values pasted from infrastructure docs for container memory limits.","solutions":["Cap the setting at 4096 or below — for wasm32 that is the entire addressable maximum anyway","Double-check units: the field is megabytes, so 4096 already means 4 GB","If a tool genuinely needs more memory than 4 GB, it cannot run as a 32-bit WASM module — run it under runtime.kind = \"native\"","Keep the value realistic for actual modules (most tools need tens to hundreds of MB)"],"exampleFix":"# before\n[runtime.wasm]\nmemory_limit_mb = 16384\n\n# after\n[runtime.wasm]\nmemory_limit_mb = 512","handlingStrategy":"validation","validationCode":"const MAX_WASM_MB: u32 = 4096;\nif cfg.memory_limit_mb > MAX_WASM_MB {\n    // reject at config load with a unit hint (field is megabytes; 4096 == 4 GB == wasm32 max)\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = platform.validate_config() {\n    if e.to_string().contains(\"4 GB safety limit\") {\n        // unit/typo problem: clamp to <=4096 or move the workload to native runtime\n    }\n}","preventionTips":["Treat >4096 as a unit mistake by default — the field is MB, not bytes","Keep wasm tool memory budgets in the tens-to-hundreds of MB","If a tool needs >4 GB, it belongs on the native runtime, not wasm32"],"tags":["rust","zeroclaw","wasm","config","limits","validation"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}