Repository navigation
Conversation
Mirror native RtlVirtualUnwind and WasmUnwindStackFrameCore when unwinding a WASM ReadyToRun frame: - Always advance SP to the caller's stack pointer. When the caller is not R2R code, report a null IP and FP instead of nulling SP, so the walk continues through the Frame chain from the right stack position. - When the frame being unwound has a reverse P/Invoke frame in its GC info and is not a funclet, its caller is native code. Report no R2R caller rather than reading the native caller's stack bytes as an R2R frame record. Expose GCInfoHeader.HasReversePInvokeFrame from both the common decoder and the x86 decoder. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ntexts Mirror native SoftwareExceptionFrame::UpdateRegDisplay_Impl and InlinedCallFrame::UpdateRegDisplay_Impl on WASM: - WASM's callee-saved register set is InterpreterFP, so restore IP, SP, and FP from a SoftwareExceptionFrame's saved context. The CalleeSavedRegisters data descriptor is empty on WASM, so the base handler left FP from the previous frame. - Return before any update for an inactive InlinedCallFrame, including the interpreter-frame stash, as native does. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #135140 (base
lewing-cdac-wasm-stackwalk-fixes@6d044c16421). This PR closes stack-walk gaps that #135140 leaves out of scope.Changes
Reverse P/Invoke boundary. Native
RtlVirtualUnwind(src/coreclr/vm/wasm/helpers.cpp) setscallerIsNativewhen the frame being unwound has a reverse P/Invoke frame in its GC info and is not a funclet.WasmUnwindStackFrameCorethen reports IP 0 instead of reading the native caller's stack as an R2R frame. The cDAC had no such check, so unwinding out of anUnmanagedCallersOnlyR2R method could make up a managed caller from native stack bytes.WasmUnwinder.TryUnwindOneFrametakes the current control PC and mirrors this check.WasmContext.Unwindrecomputes FP only for an R2R caller, as native does.GCInfoHeader.HasReversePInvokeFrameis new and set by both the common decoder and the x86 decoder (InfoHdr.RevPInvokeOffset).SoftwareExceptionFrame FP. On WASM the callee-saved register set is
InterpreterFP(ENUM_CALLEE_SAVED_REGISTERSinvm/wasm/cgencpu.h), so nativeSoftwareExceptionFrame::UpdateRegDisplay_Implrestores FP along with IP and SP. The cDAC base handler copies only the registers listed in theCalleeSavedRegistersdescriptor, which is empty on WASM, so FP was left over from the previous frame.WasmFrameHandlernow restores all three from the saved context.Inactive InlinedCallFrame. Native returns before any update when the frame has no active call.
WasmFrameHandlerchecked only after it had already written the interpreter-frame stash.StackWalk.mdandGCInfo.mdare updated.Not included
IStackWalk.GetRuntimeFramePointeron WASM. NativeGetFramePointerWorkerusesGetRegdisplayStackMark, which has noTARGET_WASMimplementation (src/coreclr/inc/regdisp.h), so there's no native behavior to mirror. It needs a runtime decision first.GetWasmFunctionIdentity. It goes in a separate PR stacked on [cDAC][wasm] Continue stack walks from a TransitionFrame into its R2R caller #135140.Validation
./.dotnet/dotnet test src/native/managed/cdac/tests/UnitTests/Microsoft.Diagnostics.DataContractReader.Tests.csproj: passed, 3312/3312../build.sh -s tools.cdactests -test: passed (UnitTests, DataGeneratorTests, UsageTests).pwsh src/native/managed/cdac/tools/CdacUsageGraph/generate-docs.ps1 -Check: passed.TryUnwindOneFrame_CallerWithoutVirtualIp_PreservesCallerStackPointerTryUnwindOneFrame_ReversePInvokeFrame_DoesNotReadNativeCallerAsR2RFrame: reverse P/Invoke, funclet with reverse P/Invoke GC info, and ordinary methodUnwind_ReversePInvokeFrame_KeepsCallerStackPointerAndClearsInstructionAndFramePointersGCInfoHeader_ReportsReversePInvokeFrame: hand-encoded WASM fat header and x86 header, with and without the frameUpdateContextFromFrame_WasmSoftwareExceptionFrame_RestoresFramePointerUpdateContextFromFrame_WasmInactiveInlinedCallFrameOverInterpreterFrame_LeavesContextUnchangedUnwindboundary testUnwindboundary testHasReversePInvokeFramealways falseSoftwareExceptionFrameoverride0x41040, got the stale0x700000x70000Note
This PR description was generated with GitHub Copilot.