Skip to content

Commit 07b0519

Browse files
authored
[10.0/preview-2] JIT: disable array stack allocation (#113181)
* [10.0/preview-2] JIT: disable array stack allocation Preview 2 is missing an important fix for stack-allocated arrays of GC types: #112711. This can lead to unexpected crashes in jitted code. Disable array stack allocation to work around this. * adjust test case
1 parent 143f7e2 commit 07b0519

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/coreclr/jit/jitconfigvalues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ RELEASE_CONFIG_INTEGER(JitObjectStackAllocationRefClass, "JitObjectStackAllocati
673673
RELEASE_CONFIG_INTEGER(JitObjectStackAllocationBoxedValueClass, "JitObjectStackAllocationBoxedValueClass", 1)
674674
RELEASE_CONFIG_INTEGER(JitObjectStackAllocationConditionalEscape, "JitObjectStackAllocationConditionalEscape", 1)
675675
CONFIG_STRING(JitObjectStackAllocationConditionalEscapeRange, "JitObjectStackAllocationConditionalEscapeRange")
676-
RELEASE_CONFIG_INTEGER(JitObjectStackAllocationArray, "JitObjectStackAllocationArray", 1)
676+
RELEASE_CONFIG_INTEGER(JitObjectStackAllocationArray, "JitObjectStackAllocationArray", 0)
677677
RELEASE_CONFIG_INTEGER(JitObjectStackAllocationSize, "JitObjectStackAllocationSize", 528)
678678

679679
RELEASE_CONFIG_INTEGER(JitEECallTimingInfo, "JitEECallTimingInfo", 0)

src/tests/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ public static int TestEntryPoint()
156156
// Stack allocation of boxed structs is now enabled
157157
CallTestAndVerifyAllocation(BoxSimpleStructAndAddFields, 12, expectedAllocationKind);
158158

159-
// Fixed-sized stack array cases
160-
CallTestAndVerifyAllocation(AllocateArrayWithNonGCElements, 84, expectedAllocationKind);
161-
CallTestAndVerifyAllocation(AllocateArrayWithGCElements, 84, expectedAllocationKind);
162-
CallTestAndVerifyAllocation(AllocateArrayT<int>, 84, expectedAllocationKind);
163-
CallTestAndVerifyAllocation(AllocateArrayT<string>, 84, expectedAllocationKind);
164-
165159
// The remaining tests currently never allocate on the stack
166160
if (expectedAllocationKind == AllocationKind.Stack) {
167161
expectedAllocationKind = AllocationKind.Heap;
168162
}
169163

164+
// Fixed-sized stack array cases (allocate in 10p2 because we've disabled array stack allocation)
165+
CallTestAndVerifyAllocation(AllocateArrayWithNonGCElements, 84, expectedAllocationKind);
166+
CallTestAndVerifyAllocation(AllocateArrayWithGCElements, 84, expectedAllocationKind);
167+
CallTestAndVerifyAllocation(AllocateArrayT<int>, 84, expectedAllocationKind);
168+
CallTestAndVerifyAllocation(AllocateArrayT<string>, 84, expectedAllocationKind);
169+
170170
// This test calls CORINFO_HELP_ISINSTANCEOFCLASS
171171
CallTestAndVerifyAllocation(AllocateSimpleClassAndCheckTypeHelper, 1, expectedAllocationKind);
172172

0 commit comments

Comments
 (0)