From 5b97e440504a9071ac7fa3bfda60459005c1e709 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 27 Aug 2026 20:28:17 -0500 Subject: [PATCH 1/2] [wasm] Fail hard when a Webcil R2R image is not valid wasm When a per-assembly R2R .wasm sibling exists but fails to parse as a WebAssembly module (e.g. a function type exceeding the wasm parameter limit), the runtime silently treated this the same as "no R2R image for this assembly" and fell back to fully interpreting the assembly. The only trace was an unrelated-looking "Ready to Run header not found" log line, so a broken R2R image could go completely unnoticed. Since the file exists, this is not the legitimate fallback case - throw instead of returning false so the failure is loud. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7f88abc1-143e-4858-b69f-ce01228a87ad --- src/coreclr/hosts/corerun/wasm/libCorerun.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index 510e9039b0e372..b3832be369795b 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -195,8 +195,8 @@ function libCoreRunFactory() { wasmModule = new WebAssembly.Module(wasmBytes); } catch (e) { const errorMessage = e instanceof Error ? e.message : String(e); - console.error("Failed to construct WebAssembly module for Webcil image:", { wasmPath, errorMessage }); - return false; + console.error("Invalid WebAssembly module for Webcil image:", { wasmPath, errorMessage }); + throw new Error(`Invalid WebAssembly module for Webcil image '${wasmPath}': ${errorMessage}`); } const tableStartIndex = wasmTable.length; From 75a60634b4eae7577846a0619fbb45a39f0a7953 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 27 Aug 2026 20:38:25 -0500 Subject: [PATCH 2/2] Clarify wording: rejected by the engine, not invalid wasm The module is well-formed wasm; it's rejected because it exceeds an implementation-defined limit (e.g. the wasm parameter count), not because it's malformed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7f88abc1-143e-4858-b69f-ce01228a87ad --- src/coreclr/hosts/corerun/wasm/libCorerun.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index b3832be369795b..4d0d4f80a275e8 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -195,8 +195,8 @@ function libCoreRunFactory() { wasmModule = new WebAssembly.Module(wasmBytes); } catch (e) { const errorMessage = e instanceof Error ? e.message : String(e); - console.error("Invalid WebAssembly module for Webcil image:", { wasmPath, errorMessage }); - throw new Error(`Invalid WebAssembly module for Webcil image '${wasmPath}': ${errorMessage}`); + console.error("Failed to construct WebAssembly module for Webcil image:", { wasmPath, errorMessage }); + throw new Error(`Failed to construct WebAssembly module for Webcil image '${wasmPath}': ${errorMessage}`); } const tableStartIndex = wasmTable.length;