Skip to content

Commit

Permalink
Fix gcroot SOS command on arm/arm64 (#90658)
Browse files Browse the repository at this point in the history
Faulted in DAC because the HelperMethodFrame's REGDISPLAY CurrentContextPointers were not initialized correctly.

Fixes issue dotnet/diagnostics#3726

Co-authored-by: Mike McLaughlin <mikem@microsoft.com>
  • Loading branch information
github-actions[bot] and mikem8361 authored Aug 16, 2023
1 parent 5b056da commit 9dc05ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/coreclr/vm/arm/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,16 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
pRD->pCurrentContext->R10 = (DWORD)(pUnwoundState->captureR4_R11[6]);
pRD->pCurrentContext->R11 = (DWORD)(pUnwoundState->captureR4_R11[7]);

pRD->pCurrentContextPointers->R4 = &pRD->pCurrentContext->R4;
pRD->pCurrentContextPointers->R5 = &pRD->pCurrentContext->R5;
pRD->pCurrentContextPointers->R6 = &pRD->pCurrentContext->R6;
pRD->pCurrentContextPointers->R7 = &pRD->pCurrentContext->R7;
pRD->pCurrentContextPointers->R8 = &pRD->pCurrentContext->R8;
pRD->pCurrentContextPointers->R9 = &pRD->pCurrentContext->R9;
pRD->pCurrentContextPointers->R10 = &pRD->pCurrentContext->R10;
pRD->pCurrentContextPointers->R11 = &pRD->pCurrentContext->R11;
pRD->pCurrentContextPointers->Lr = &pRD->pCurrentContext->Lr;

return;
}
#endif // DACCESS_COMPILE
Expand Down
24 changes: 12 additions & 12 deletions src/coreclr/vm/arm64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,18 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
pRD->pCurrentContext->Fp = (DWORD64)(pUnwoundState->captureX19_X29[10]);
pRD->pCurrentContext->Lr = NULL; // Unwind again to get Caller's PC

pRD->pCurrentContextPointers->X19 = pUnwoundState->ptrX19_X29[0];
pRD->pCurrentContextPointers->X20 = pUnwoundState->ptrX19_X29[1];
pRD->pCurrentContextPointers->X21 = pUnwoundState->ptrX19_X29[2];
pRD->pCurrentContextPointers->X22 = pUnwoundState->ptrX19_X29[3];
pRD->pCurrentContextPointers->X23 = pUnwoundState->ptrX19_X29[4];
pRD->pCurrentContextPointers->X24 = pUnwoundState->ptrX19_X29[5];
pRD->pCurrentContextPointers->X25 = pUnwoundState->ptrX19_X29[6];
pRD->pCurrentContextPointers->X26 = pUnwoundState->ptrX19_X29[7];
pRD->pCurrentContextPointers->X27 = pUnwoundState->ptrX19_X29[8];
pRD->pCurrentContextPointers->X28 = pUnwoundState->ptrX19_X29[9];
pRD->pCurrentContextPointers->Fp = pUnwoundState->ptrX19_X29[10];
pRD->pCurrentContextPointers->Lr = NULL;
pRD->pCurrentContextPointers->X19 = &pRD->pCurrentContext->X19;
pRD->pCurrentContextPointers->X20 = &pRD->pCurrentContext->X20;
pRD->pCurrentContextPointers->X21 = &pRD->pCurrentContext->X21;
pRD->pCurrentContextPointers->X22 = &pRD->pCurrentContext->X22;
pRD->pCurrentContextPointers->X23 = &pRD->pCurrentContext->X23;
pRD->pCurrentContextPointers->X24 = &pRD->pCurrentContext->X24;
pRD->pCurrentContextPointers->X25 = &pRD->pCurrentContext->X25;
pRD->pCurrentContextPointers->X26 = &pRD->pCurrentContext->X26;
pRD->pCurrentContextPointers->X27 = &pRD->pCurrentContext->X27;
pRD->pCurrentContextPointers->X28 = &pRD->pCurrentContext->X28;
pRD->pCurrentContextPointers->Fp = &pRD->pCurrentContext->Fp;
pRD->pCurrentContextPointers->Lr = &pRD->pCurrentContext->Lr;

return;
}
Expand Down

0 comments on commit 9dc05ee

Please sign in to comment.