diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2017-08-26 23:46:42 +0300 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2017-08-26 23:46:42 +0300 |
commit | e522eee8239cd50fed6571f7d485e77930461a0c (patch) | |
tree | 034726a962b73ca4efde90d415a6b24988e5cad5 /src/Native | |
parent | c9b68da855f46b02aeb3540b812078da1ca40b17 (diff) |
Fixing a bug in the GCStress implementation where RhpGcStressProbe trashes the last error value . This is done by saving the last error value (using GetLastError) before calling GarbageCollect and then restoring it (using SetLastError). Therefore, re-enabling the tests that were disabled for GC runs in response of Bug 477586 and 477587. Changing StressGc method to have a single return point.
[tfs-changeset: 1671927]
Diffstat (limited to 'src/Native')
-rw-r--r-- | src/Native/Runtime/gcrhenv.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Native/Runtime/gcrhenv.cpp b/src/Native/Runtime/gcrhenv.cpp index 477661a68..8a50a25cf 100644 --- a/src/Native/Runtime/gcrhenv.cpp +++ b/src/Native/Runtime/gcrhenv.cpp @@ -598,12 +598,17 @@ EXTERN_C UInt32_BOOL g_fGcStressStarted = UInt32_FALSE; // UInt32_BOOL because a // static void RedhawkGCInterface::StressGc() { - if (!g_fGcStressStarted || GetThread()->IsSuppressGcStressSet() || GetThread()->IsDoNotTriggerGcSet()) + // The GarbageCollect operation below may trash the last win32 error. We save the error here so that it can be + // restored after the GC operation; + Int32 lastErrorOnEntry = PalGetLastError(); + + if (g_fGcStressStarted && !GetThread()->IsSuppressGcStressSet() && !GetThread()->IsDoNotTriggerGcSet()) { - return; + GCHeapUtilities::GetGCHeap()->GarbageCollect(); } - GCHeapUtilities::GetGCHeap()->GarbageCollect(); + // Restore the saved error + PalSetLastError(lastErrorOnEntry); } #endif // FEATURE_GC_STRESS |