From 9b58e442467667b49163fdfd961b232d105ad495 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Nov 2021 15:36:36 -0800 Subject: [PATCH] Preserve last error in call-counting stubs (#60887) Fixes #60819 Co-authored-by: Jan Kotas --- src/coreclr/vm/callcounting.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index bdc4bc8..5a3561c 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -715,14 +715,13 @@ extern "C" PCODE STDCALL OnCallCountThresholdReached(TransitionBlock *transition PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transitionBlock, TADDR stubIdentifyingToken) { - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_COOPERATIVE; - PRECONDITION(CheckPointer(transitionBlock)); - } - CONTRACTL_END; + STATIC_CONTRACT_THROWS; + STATIC_CONTRACT_GC_TRIGGERS; + STATIC_CONTRACT_MODE_COOPERATIVE; + + PCODE codeEntryPoint; + + BEGIN_PRESERVE_LAST_ERROR; MAKE_CURRENT_THREAD_AVAILABLE(); @@ -740,8 +739,6 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti CallCountingHelperFrame *frame = &frameWithCookie; frame->Push(CURRENT_THREAD); - PCODE codeEntryPoint; - INSTALL_MANAGED_EXCEPTION_DISPATCHER; INSTALL_UNWIND_AND_CONTINUE_HANDLER; @@ -786,6 +783,9 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; frame->Pop(CURRENT_THREAD); + + END_PRESERVE_LAST_ERROR; + return codeEntryPoint; } -- 2.7.4