Skip to content

Commit 93e1714

Browse files
Merge pull request #262 from Unity-Technologies/fix-collectible-szarray-in-frozenheap
Fixed SzArray from Collectible LoaderAllocator being allocated in frozen heap
2 parents 92cf035 + 2bb0487 commit 93e1714

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51918,7 +51918,7 @@ void CFinalize::CheckFinalizerObjects()
5191851918
void gc_heap::walk_heap_per_heap (walk_fn fn, void* context, int gen_number, BOOL walk_large_object_heap_p)
5191951919
{
5192051920
generation* gen = gc_heap::generation_of (gen_number);
51921-
heap_segment* seg = heap_segment_in_range (generation_start_segment (gen));
51921+
heap_segment* seg = generation_start_segment (gen);
5192251922
uint8_t* x = ((gen_number == max_generation) ? heap_segment_mem (seg) : get_soh_start_object (seg, gen));
5192351923
uint8_t* end = heap_segment_allocated (seg);
5192451924
int align_const = get_alignment_constant (TRUE);
@@ -51928,7 +51928,7 @@ void gc_heap::walk_heap_per_heap (walk_fn fn, void* context, int gen_number, BOO
5192851928
{
5192951929
if (x >= end)
5193051930
{
51931-
if ((seg = heap_segment_next_in_range (seg)) != 0)
51931+
if ((seg = heap_segment_next (seg)) != 0)
5193251932
{
5193351933
x = heap_segment_mem (seg);
5193451934
end = heap_segment_allocated (seg);
@@ -51940,7 +51940,7 @@ void gc_heap::walk_heap_per_heap (walk_fn fn, void* context, int gen_number, BOO
5194051940
// advance to next lower generation
5194151941
gen_number--;
5194251942
gen = gc_heap::generation_of (gen_number);
51943-
seg = heap_segment_in_range (generation_start_segment (gen));
51943+
seg = generation_start_segment (gen);
5194451944

5194551945
x = heap_segment_mem (seg);
5194651946
end = heap_segment_allocated (seg);
@@ -51952,12 +51952,12 @@ void gc_heap::walk_heap_per_heap (walk_fn fn, void* context, int gen_number, BOO
5195251952
if (walk_large_object_heap_p)
5195351953
{
5195451954
walk_large_object_heap_p = FALSE;
51955-
seg = heap_segment_in_range (generation_start_segment (large_object_generation));
51955+
seg = generation_start_segment (large_object_generation);
5195651956
}
5195751957
else if (walk_pinned_object_heap)
5195851958
{
5195951959
walk_pinned_object_heap = FALSE;
51960-
seg = heap_segment_in_range (generation_start_segment (pinned_object_generation));
51960+
seg = generation_start_segment (pinned_object_generation);
5196151961
}
5196251962
else
5196351963
{

src/coreclr/vm/frozenobjectheap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Object* FrozenObjectHeapManager::TryAllocateObject(PTR_MethodTable type, size_t
4646
CrstHolder ch(&m_Crst);
4747

4848
_ASSERT(type != nullptr);
49+
_ASSERT(!type->Collectible());
4950
_ASSERT(FOH_COMMIT_SIZE >= MIN_OBJECT_SIZE);
5051

5152
// Currently we don't support frozen objects with special alignment requirements

src/coreclr/vm/gchelpers.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,11 @@ OBJECTREF TryAllocateFrozenSzArray(MethodTable* pArrayMT, INT32 cElements)
510510

511511
CorElementType elemType = pArrayMT->GetArrayElementType();
512512

513-
if (pArrayMT->ContainsPointers() && cElements > 0)
513+
if (pArrayMT->Collectible() || (pArrayMT->ContainsPointers() && cElements > 0))
514514
{
515-
// For arrays with GC pointers we can only work with empty arrays
515+
// We cannot allocate in the frozen heap if:
516+
// - the array type is collectible
517+
// - or for non empty arrays with GC pointers
516518
return NULL;
517519
}
518520

src/coreclr/vm/mono/mono_coreclr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ extern "C" EXPORT_API bool EXPORT_CC coreclr_unity_get_stackframe_info_from_ip(v
983983
{
984984
CONTRACTL
985985
{
986-
NOTHROW;
986+
THROWS;
987987
GC_NOTRIGGER;
988988
MODE_ANY;
989989
}

0 commit comments

Comments
 (0)