{
#if defined(STRESS_HEAP) && !defined(FEATURE_REDHAWK)
alloc_context* acontext = static_cast<alloc_context*>(context);
+ assert(context != nullptr);
// if GC stress was dynamically disabled during this run we return FALSE
if (!GCStressPolicy::IsEnabled())
#ifndef MULTIPLE_HEAPS
static int32_t OneAtATime = -1;
- if (acontext == 0)
- acontext = generation_alloc_context (pGenGCHeap->generation_of(0));
-
// Only bother with this if the stress level is big enough and if nobody else is
// doing it right now. Note that some callers are inside the AllocLock and are
// guaranteed synchronized. But others are using AllocationContexts and have no
#endif //_PREFAST_
#endif //MULTIPLE_HEAPS
-#ifndef FEATURE_REDHAWK
- GCStress<gc_on_alloc>::MaybeTrigger(generation_alloc_context(hp->generation_of(0)));
-#endif // FEATURE_REDHAWK
-
alloc_context* acontext = generation_alloc_context (hp->generation_of (max_generation+1));
newAlloc = (Object*) hp->allocate_large_object (size + ComputeMaxStructAlignPadLarge(requiredAlignment), acontext->alloc_bytes_loh);
===========================================================================
*/
- // Returns TRUE if GC actually happens, otherwise FALSE
- virtual BOOL StressHeap(gc_alloc_context* acontext = 0) = 0;
+ // Returns TRUE if GC actually happens, otherwise FALSE. The passed alloc context
+ // must not be null.
+ virtual BOOL StressHeap(gc_alloc_context* acontext) = 0;
/*
===========================================================================
// 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.
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)
{
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;