Skip to content

Fix HelperMethodFrame::UpdateRegDisplay on x86#65589

Merged
jkotas merged 1 commit intodotnet:mainfrom
janvorli:fix-helpermethodframe-updateregdisplay-x86
Feb 19, 2022
Merged

Fix HelperMethodFrame::UpdateRegDisplay on x86#65589
jkotas merged 1 commit intodotnet:mainfrom
janvorli:fix-helpermethodframe-updateregdisplay-x86

Conversation

@janvorli
Copy link
Member

While running managed debugger tests with x86 runtime debug build, I was
hiting an assert in MachineState::pRetAddress() method in a couple of
tests.
It turns out there was a bug in the HelperMethodFrame::UpdateRegDisplay
introduced about 5 years ago that only happens in DAC. The m_MachState
can be uninitialized when we enter the method and we were calling
m_MachState.pRetAddr() before performing the initialization.

This change fixes it.

While running managed debugger tests with x86 runtime debug build, I was
hiting an assert in MachineState::pRetAddress() method in a couple of
tests.
It turns out there was a bug in the HelperMethodFrame::UpdateRegDisplay
introduced about 5 years ago that only happens in DAC. The m_MachState
can be uninitialized when we enter the method and we were calling
m_MachState.pRetAddr() before performing the initialization.

This change fixes it.
@janvorli janvorli requested a review from jkotas February 18, 2022 21:34
@janvorli janvorli self-assigned this Feb 18, 2022
@janvorli
Copy link
Member Author

cc: @hoyosjs


InsureInit(false, pUnwoundState);

pRD->PCTAddr = dac_cast<TADDR>(pUnwoundState->pRetAddr());
Copy link
Member

Choose a reason for hiding this comment

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

Do you know how this branch doesn't trigger the precondition? Sounds like this precondition is only valid in the HMF case for the in-proc unwinder and not for the DAC

Copy link
Member

Choose a reason for hiding this comment

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

Can contracts be ifdef to be only valid in not the dac? Like

#ifndef DACCESS_COMPILE
// InsureInit has been called
PRECONDITION(m_MachState.isValid()); 
#endif // DACCESS_COMPILE

Copy link
Member Author

Choose a reason for hiding this comment

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

Contracts are not compiled for DAC at all (the contract macro definitions are empty for that case). See here:

// Also, we won't enable contracts if this is a DAC build.
#if defined(ENABLE_CONTRACTS_DATA) && !defined(DACCESS_COMPILE) && !defined(CROSS_COMPILE)
#define ENABLE_CONTRACTS
#endif

Copy link
Member

@hoyosjs hoyosjs left a comment

Choose a reason for hiding this comment

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

For the DAC, this looks like the correct fix.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM

@jkotas jkotas merged commit 0419950 into dotnet:main Feb 19, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to 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.

3 participants