Skip to content

Commit

Permalink
Ensure that a native code version only ever gets one entry point that…
Browse files Browse the repository at this point in the history
… doesn't change (#94542)

- Fixed `MethodDesc::SetNativeCodeInterlocked` to use the passed-in expected entry point instead of the current entry point. It seems this is how it used to work before #57707.
- It's possible for a method to get jitted multiple times on the same thread due to reentry through class construction. Once a native code version is updated with an entry point, it can run and there are times when it's necessary to look up the native code version corresponding to the currently running code, such as when installing patchpoints. That would be impossible if the entry point is changed meanwhile to a different entry point.

Fixes #93849
  • Loading branch information
kouvel authored Nov 9, 2023
1 parent aa08b4a commit 8c02b08
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3311,13 +3311,7 @@ BOOL MethodDesc::SetNativeCodeInterlocked(PCODE addr, PCODE pExpected /*=NULL*/)
}
#endif

PTR_PCODE pSlot = GetAddrOfNativeCodeSlot();
NativeCodeSlot expected;

expected = *pSlot;

return InterlockedCompareExchangeT(reinterpret_cast<TADDR*>(pSlot),
(TADDR&)addr, (TADDR&)expected) == (TADDR&)expected;
return InterlockedCompareExchangeT(GetAddrOfNativeCodeSlot(), addr, pExpected) == pExpected;
}

_ASSERTE(pExpected == NULL);
Expand Down

0 comments on commit 8c02b08

Please sign in to comment.