Skip to content

Wasm: stop R2R stack walk at reverse-pinvoke frames - #131668

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-rpi-unwind
Open

Wasm: stop R2R stack walk at reverse-pinvoke frames#131668
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-rpi-unwind

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Fixes a failure seen in #131493 (enable SPC R2R). We were walking off the end of the managed part of the shadow stack at a reverse pinvoke boundary.

Fixes a failure seen in dotnet#131493 (enable SPC R2R). We were walking
off the end of the managed part of the shadow stack at a reverse
pinvoke boundary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 89caa9c8-5b0f-4fcc-a8c4-726ac8535110
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@dotnet/wasm-contrib PTAL

Not sure who best to tag as a reviewer given that David is away for a few days. @janvorli ?

@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.

Copilot AI 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

Updates the WASM RtlVirtualUnwind implementation to stop R2R shadow-stack-based unwinding when the current frame is a reverse-P/Invoke boundary (i.e., the managed frame’s caller is native), preventing the unwind from treating a native caller SP as a managed shadow frame.

Changes:

  • Extends WasmUnwindStackFrameCore to optionally leave the caller IP unset when the caller is native.
  • Detects reverse-P/Invoke frames via GC info (DECODE_REVERSE_PINVOKE_VAR) and uses that to terminate the R2R walk at the native boundary.

Comment on lines +1855 to +1857
EECodeInfo codeInfo;
codeInfo.Init((PCODE)ControlPc);
if (codeInfo.IsValid())
@AndyAyersMS AndyAyersMS added the arch-wasm WebAssembly architecture label Jul 31, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-VM-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants