') + ')', '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); } })(); })(); Crossgen2: don't mutate getCallInfo token by AndyAyersMS · Pull Request #132186 · dotnet/runtime · GitHub
Skip to content

Crossgen2: don't mutate getCallInfo token - #132186

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-crossgen2-getcallinfo-token
Aug 12, 2026
Merged

Crossgen2: don't mutate getCallInfo token#132186
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-crossgen2-getcallinfo-token

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Crossgen2 uses a private tokenType marker while resolving static virtual interface calls. Since getCallInfo receives the resolved token as input, mutating the caller's token causes SuperPMI to record a different lookup key after the call completes.

Copy the resolved token before applying Crossgen2's internal bookkeeping and use the copy throughout getCallInfo.

Validation:

  • Browser/wasm CoreLib collection: GetCallInfo replay failures reduced from 1,089 to zero.
  • Windows x64 CoreLib Crossgen2 collection replayed clean.

Note

This pull request was created with GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4a1c1a0f-9329-402a-ac6d-b19087898fa6
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Crossgen2 correctness issue where getCallInfo (which conceptually treats the resolved token as an input) was mutating the caller-provided CORINFO_RESOLVED_TOKEN as a side effect of internal constraint-resolution bookkeeping, causing SuperPMI to record an inconsistent lookup key after the call.

Changes:

  • Copy pResolvedToken into a local resolvedToken at the start of getCallInfo.
  • Route internal calls that may observe/modify token bookkeeping (ceeInfoGetCallInfo and subsequent ComputeMethodWithToken uses) through the copied token, preventing mutation from leaking to the caller.

@AndyAyersMS

AndyAyersMS commented Aug 11, 2026

Copy link
Copy Markdown
MemberAuthor

@adamperlin ptal
fyi @dotnet/jit-contrib

Crossgen2 was mutating a CORINFO_RESOLVED_TOKEN input. This mutation was never seen by the JIT, but was captured by SPMI, leading to a key mismatch on replay.

Note these 1000+ contexts with failures were filtered out during SPMI collection's cleanup phase, so we never would see them in the downloaded file.

@adamperlinadamperlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix makes sense to me, but I'm wondering why this case only comes up on Wasm?
EDIT: I guess it isn't specific to Wasm since I see you mentioned Windows x64 CoreLib as validation too.

@AndyAyersMS

AndyAyersMS commented Aug 12, 2026

Copy link
Copy Markdown
MemberAuthor

It is not wasm specific, see eg this linux x64 cleanup log

https://helixr0107v0xdcypoyl9e7f.blob.core.windows.net/dotnet-runtime-refs-heads-main-f595e984a91c408dbd/1/1/console.f744f0b4.log?sv=2026-02-06&se=2026-11-09T15%3A36%3A47Z&sr=c&sp=rl&sig=M9FX9%2FOtr3vOl22fD0xRyzHYB9722vSM55usE9U%2FbQ8%3D

but it looks like those collections have other problems too, while Wasm was dominated by getCallInfo -- will have to investigate.

@AndyAyersMS
AndyAyersMS merged commit c2d7ecb into dotnet:mainAug 12, 2026
103 of 105 checks passed
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-rc1 milestone Aug 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@AndyAyersMS@adamperlin