summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorSean Gillespie <sean@swgillespie.me>2017-03-22 10:25:08 -0700
committerGitHub <noreply@github.com>2017-03-22 10:25:08 -0700
commit992d37064fa76ea7633734607381545e228806a5 (patch)
tree4b7cf456449feb58ee126fe4a065bb8f2ad54afb /src/vm
parentc2ba64de40e5e28c56b9734521c5f6ead20bdea9 (diff)
downloadcoreclr-992d37064fa76ea7633734607381545e228806a5.tar.gz
coreclr-992d37064fa76ea7633734607381545e228806a5.tar.bz2
coreclr-992d37064fa76ea7633734607381545e228806a5.zip
Fix an issue where GCStress allocated objects using the Gen 0 alloc context (#10322)
* Fix an issue where GCStress allocated objects using the Gen 0 alloc context * Remove a GCStress MaybeTrigger on LOH allocations that attempted to use the gen 0 alloc context
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/gccover.cpp5
-rw-r--r--src/vm/gcstress.h7
-rw-r--r--src/vm/threadsuspend.cpp6
3 files changed, 15 insertions, 3 deletions
diff --git a/src/vm/gccover.cpp b/src/vm/gccover.cpp
index 02bb0de5e0..3e195796b4 100644
--- a/src/vm/gccover.cpp
+++ b/src/vm/gccover.cpp
@@ -1759,7 +1759,10 @@ void DoGcStress (PCONTEXT regs, MethodDesc *pMD)
// Do the actual stress work
//
- if (!GCHeapUtilities::GetGCHeap()->StressHeap())
+ // BUG(github #10318) - when not using allocation contexts, the alloc lock
+ // must be acquired here. Until fixed, this assert prevents random heap corruption.
+ assert(GCHeapUtilities::UseThreadAllocationContexts());
+ if (!GCHeapUtilities::GetGCHeap()->StressHeap(GetThread()->GetAllocContext()))
UpdateGCStressInstructionWithoutGC ();
// Must flush instruction cache before returning as instruction has been modified.
diff --git a/src/vm/gcstress.h b/src/vm/gcstress.h
index 04487c611e..edf92a947c 100644
--- a/src/vm/gcstress.h
+++ b/src/vm/gcstress.h
@@ -286,7 +286,12 @@ namespace _GCStress
public:
FORCEINLINE
static void Trigger()
- { GCHeapUtilities::GetGCHeap()->StressHeap(); }
+ {
+ // BUG(github #10318) - when not using allocation contexts, the alloc lock
+ // must be acquired here. Until fixed, this assert prevents random heap corruption.
+ _ASSERTE(GCHeapUtilities::UseThreadAllocationContexts());
+ GCHeapUtilities::GetGCHeap()->StressHeap(GetThread()->GetAllocContext());
+ }
FORCEINLINE
static void Trigger(::gc_alloc_context* acontext)
diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp
index 52c4aa62c3..10032fd08f 100644
--- a/src/vm/threadsuspend.cpp
+++ b/src/vm/threadsuspend.cpp
@@ -3495,7 +3495,11 @@ void Thread::PerformPreemptiveGC()
{
GCX_COOP();
m_bGCStressing = TRUE;
- GCHeapUtilities::GetGCHeap()->StressHeap();
+
+ // BUG(github #10318) - when not using allocation contexts, the alloc lock
+ // must be acquired here. Until fixed, this assert prevents random heap corruption.
+ _ASSERTE(GCHeapUtilities::UseThreadAllocationContexts());
+ GCHeapUtilities::GetGCHeap()->StressHeap(GetThread()->GetAllocContext());
m_bGCStressing = FALSE;
}
m_GCOnTransitionsOK = TRUE;