') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Wasm / R2R: conv_ovf_i8_i aborts at runtime (try / catch [OverflowException] around conv.ovf.i) · Issue #129337 · dotnet/runtime · GitHub
Skip to content

Wasm / R2R: conv_ovf_i8_i aborts at runtime (try / catch [OverflowException] around conv.ovf.i) #129337

Description

@AndyAyersMS

Note

This issue text was AI-generated (GitHub Copilot CLI). I have verified the reproduction steps manually.

When the IL test JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_i8_i is compiled to R2R wasm and executed, it aborts during execution. The IL-only run passes; only the R2R version fails. crossgen2 reports success with no warnings/NYI.

Symptom

$ node --stack-size=8192 corerun.js -c $CORE_ROOT conv_ovf_i8_i/conv_ovf_i8_i.dll
# stdout: (empty)
# stderr: Aborted(Assertion failed)
# exit: 0 (expected 100)

Excluding the assembly from R2R restores PASS:

$ DOTNET_ReadyToRunExcludeList=conv_ovf_i8_i \
node --stack-size=8192 corerun.js -c $CORE_ROOT conv_ovf_i8_i/conv_ovf_i8_i.dll
# exit: 100 (PASS)

Repro

Setup is identical to #128234 / #129335. From the repo root on a wasm-EH branch (here: pr-stack-rebased with PRs #129197, #129205, #129269 and the catch_ref + throw_ref codegen integrated):

.\build clr+libs -rc debug -c release -os browser
.\src\tests\build skipmanaged browser
.\build -s clr.wasmjit -c Checked
# (copy clrjit_universal_wasm_x64.dll into all 6 crossgen2/ilc subdirs)

Then build only the one test:

cd src\tests\JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i
dotnet msbuild /p:TargetArchitecture=wasm /p:TargetOS=browser \
/p:RuntimeFlavor=coreclr /p:BuildAsStandalone=true conv_ovf_i8_i.ilproj

Run with R2R enabled:

set CORE_ROOT=<REPO_ROOT>\artifacts\tests\coreclr\browser.wasm.Debug\Tests\Core_Root
set RunCrossGen2=1
<REPO_ROOT>\artifacts\tests\coreclr\browser.wasm.Debug\JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i\conv_ovf_i8_i.cmd

Result: FAILED, stderr contains Aborted(Assertion failed), stdout is empty.

To run crossgen2 manually (matches the .cmd's response file):

crossgen2.exe ^
-O -o:conv_ovf_i8_i.wasm ^
--targetarch:wasm --targetos:browser ^
--verify-type-and-field-layout --method-layout:random -f:wasm ^
-r:%CORE_ROOT%\System.*.dll -r:%CORE_ROOT%\Microsoft.*.dll ^
-r:%CORE_ROOT%\xunit.*.dll -r:%CORE_ROOT%\mscorlib.dll -r:%CORE_ROOT%\netstandard.dll ^
-r:IL-CG2\*.dll IL-CG2\conv_ovf_i8_i.dll

crossgen2 exits 0 with only Emitting R2R Wasm file: ... on stdout. No warnings, no NYI, no JIT asserts. The produced wasm validates and instantiates without complaint from V8 (no Failed to construct WebAssembly... errors on stderr). The abort happens during execution.

Test source

src/tests/JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_i8_i.il

The test exercises conv.ovf.i and conv.ovf.i.un on int64 inputs, expecting either the converted value (on success) or OverflowException (caught and discriminated). Each conversion method uses a try { conv.ovf.i; stloc; leave } catch [System.OverflowException] { ... } pattern, so this test exercises both:

  • overflow detection on a 32-bit native int target (wasm), and
  • exception-handler entry/exit through our R2R EH codegen.

Observations

  • crossgen2 produces 14 functions: conv, conv_un, their _funclet_0 catch handlers, main, the R2R/interpreter thunks, and the WebCil entry points.
  • webcil.rtlRestoreContextTag is imported correctly with the simplified () -> () signature.
  • No EH validation errors observed on this wasm (e.g. Failed to construct WebAssembly...).
  • The abort message lacks detail (just Aborted(Assertion failed)), suggesting either a release-config wasm-side assert (likely in coreclr.wasm or corerun.wasm) or an emscripten abort() triggered by an unexpected control-flow path.

Almost certainly a real R2R codegen bug — possibly tied to:

  • conv.ovf.i lowering on a 32-bit target with a try enclosing it, or
  • funclet/EH-edge handling around the overflow-throw path that doesn't surface as wasm-validation failure but trips a runtime invariant.

Workaround

Add conv_ovf_i8_i to DOTNET_ReadyToRunExcludeList. The test then runs interpreted and passes.

Related

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions