') + ')', '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); } })(); })(); Add cDac contract for ResolveFrameHelper by leculver · Pull Request #129261 · dotnet/runtime · GitHub
Skip to content

Add cDac contract for ResolveFrameHelper - #129261

Closed
leculver wants to merge 5 commits into
dotnet:mainfrom
leculver:leculver/cdac-resolve-helper-frame
Closed

Add cDac contract for ResolveFrameHelper#129261
leculver wants to merge 5 commits into
dotnet:mainfrom
leculver:leculver/cdac-resolve-helper-frame

Conversation

@leculver

Copy link
Copy Markdown
Contributor

cDac does not support ResolveFrameHelper, leading to broken stacks/missed roots when it's on the callstack.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

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 extends the cDAC stack-walking contracts to understand ResolveHelperFrame (a resumable TransitionFrame used by interface resolve helper dispatch), so stack walking can correctly step past it and derive a correct thread context (including argument registers) from its TransitionBlock.

Changes:

  • Add a new cDAC data type/descriptor for ResolveHelperFrame (native descriptor + managed data adapter) and wire it into stack-walk frame classification/resumable handling.
  • Update platform frame handlers to support updating context from a raw TransitionBlock pointer and to update argument registers for ResolveHelperFrame where appropriate (AMD64/ARM64).
  • Extend unit test infrastructure and stack-walk tests to cover ResolveHelperFrame frame enumeration and AMD64 context reconstruction from the TransitionBlock.
Show a summary per file
FileDescription
src/native/managed/cdac/tests/UnitTests/StackWalkTests.csAdds mock target/runtime-info setup and new tests covering ResolveHelperFrame enumeration + context update.
src/native/managed/cdac/tests/UnitTests/MockDescriptors/MockDescriptors.Frame.csAdds mock layouts/builders for ResolveHelperFrame, TransitionBlock, and minimal register sets.
src/native/managed/cdac/tests/TestInfrastructure/TestPlaceholderTarget.csMakes TryGetThreadContext return false so stack-walk can use its fallback path in tests.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/DataType.csIntroduces DataType.ResolveHelperFrame.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Frames/ResolveHelperFrame.csAdds managed cDAC data adapter for ResolveHelperFrame.TransitionBlockPtr.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.csTreats ResolveHelperFrame as resumable (FRAME_ATTR_RESUMABLE) in stack-walk state tracking.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/IPlatformFrameHandler.csExtends frame-handler interface with HandleTransitionBlock and HandleResolveHelperFrame.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/FrameHelpers.csAdds ResolveHelperFrame handling for context updates and return-address retrieval.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/BaseFrameHandler.csFactors common transition-block handling and adds helper for updating argument registers from the transition block.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/ARMFrameHandler.csRoutes transition handling via HandleTransitionBlock and keeps ARM argument-register updates.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/ARM64FrameHandler.csUpdates argument registers for ResolveHelperFrame after applying the transition block.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/AMD64FrameHandler.csUpdates argument registers for ResolveHelperFrame after applying the transition block.
src/coreclr/vm/frames.hExposes ResolveHelperFrame::m_pTransitionBlock offset via cdac_data<ResolveHelperFrame>.
src/coreclr/vm/datadescriptor/datadescriptor.incEmits the native cDAC type descriptor for ResolveHelperFrame under FEATURE_RESOLVE_HELPER_DISPATCH.

Copilot's findings

  • Files reviewed: 14/14 changed files
  • Comments generated: 1

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.

Copilot's findings

  • Files reviewed: 15/15 changed files
  • Comments generated: 2

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.

Copilot's findings

  • Files reviewed: 15/15 changed files
  • Comments generated: 1

@lateralusXlateralusX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@leculver

Copy link
Copy Markdown
ContributorAuthor

Helix arm64 runs have been timing out all day. Since this feature is primarily for arm64, we need tests to run here before merging, so I'm going to hold off merging temporarily and wait until helix arm64 runs are working.

leculverand others added 5 commits June 16, 2026 14:19
Add ResolveHelperFrame to the cDAC descriptor and managed frame model so stack walking can classify it, recover return addresses, treat it as resumable, and restore transition-block context. Add unit coverage for classification and AMD64 context restoration, including argument registers.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the directly-read ResolveHelperFrame.TransitionBlockPtr field to the
contract's descriptor table and describe its handling: it uses the
TransitionFrame mechanism but additionally restores argument registers on
all platforms, and is gated by FEATURE_RESOLVE_HELPER_DISPATCH.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ARM64FrameHandler.HandleResolveHelperFrame (restoring argument registers
from the TransitionBlock) was untested. Convert the AMD64-only fact into a
theory covering X64 and Arm64: thread an explicit RuntimeInfoArchitecture
through CreateTarget to select the platform handler, and parameterize the
mock TransitionBlock register names so the Arm64 case restores x0/x19.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 16, 2026 18:19
@leculver
leculverforce-pushed the leculver/cdac-resolve-helper-frame branch from b81ab89 to 2a8047eCompareJune 16, 2026 18:19
@leculver
leculver enabled auto-merge (squash) June 16, 2026 18:19

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.

Copilot's findings

  • Files reviewed: 15/15 changed files
  • Comments generated: 1

| `SoftwareExceptionFrame` | `ReturnAddress` | Return address saved in Frame |
| `FramedMethodFrame` | `TransitionBlockPtr` | Pointer to Frame's TransitionBlock |
| `FramedMethodFrame` | `MethodDescPtr` | Pointer to Frame's method desc |
| `ResolveHelperFrame` | `TransitionBlockPtr` | Pointer to Frame's TransitionBlock (only present when `FEATURE_RESOLVE_HELPER_DISPATCH` is defined) |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was test-only code for Native AOT. I do not think it is currently reachable.

Are you able to actually hit this in tests?

@leculverleculverJun 18, 2026

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, this is from code review only. I mostly want to make sure that we aren't missing a cDac contract for some scenario which would require servicing later. This seems to be the only coreclr!Frame that isn't wrapped. If this is pure test code that will never ship, I will close this PR. That wasn't obvious from source inspection.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Scanning through it looks like DOTNET_JitForceControlFlowGuard=1 can still reach this, and this code is dac-ized in the legacy dac. Seems like it would be safer to wrap it in case we need to debug something where it shows up.

I'm happy to close without merging if you disagree though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think it is reachable currently.

ResolveHelperFrame is only used by VSD_ResolveWorkerForInterfaceLookupSlot. VSD_ResolveWorkerForInterfaceLookupSlot is only called by JIT_InterfaceLookupForSlot. JIT_InterfaceLookupForSlot ID is CORINFO_HELP_INTERFACELOOKUP_FOR_SLOT.CORINFO_HELP_INTERFACELOOKUP_FOR_SLOT is never emitted by the JIT currently.

I think you can delete this whole chain if you would like.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks! I'll close this one and open a new one to do exactly that.

auto-merge was automatically disabled June 21, 2026 14:17

Pull request was closed

@leculver
leculver deleted the leculver/cdac-resolve-helper-frame branch June 21, 2026 14:18
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 22, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@leculver@noahfalk@jkotas@lateralusX