@@ -434,7 +434,8 @@ OBJECTREF AllocateSzArray(MethodTable* pArrayMT, INT32 cElements, GC_ALLOC_FLAGS
434
434
// dummy object.
435
435
// If the GC gives us a 8 byte aligned address, we use it for the array and place the dummy
436
436
// object after the array, otherwise we put the dummy object first, shifting the base of
437
- // the array to an 8 byte aligned address.
437
+ // the array to an 8 byte aligned address. Also, we need to make sure that the syncblock of the
438
+ // second object is zeroed. GC won't take care of zeroing it out with GC_ALLOC_ZEROING_OPTIONAL.
438
439
//
439
440
// Note: on 64 bit platforms, the GC always returns 8 byte aligned addresses, and we don't
440
441
// execute this code because DATA_ALIGNMENT < sizeof(double) is false.
@@ -447,14 +448,24 @@ OBJECTREF AllocateSzArray(MethodTable* pArrayMT, INT32 cElements, GC_ALLOC_FLAGS
447
448
orArray = (ArrayBase*)Alloc (totalSize + MIN_OBJECT_SIZE, flags);
448
449
449
450
Object* orDummyObject;
450
- if ((size_t )orArray % sizeof (double ))
451
+ if ((( size_t )orArray % sizeof (double )) != 0 )
451
452
{
452
453
orDummyObject = orArray;
453
454
orArray = (ArrayBase*)((size_t )orArray + MIN_OBJECT_SIZE);
455
+ if (flags & GC_ALLOC_ZEROING_OPTIONAL)
456
+ {
457
+ // clean the syncblock of the aligned array.
458
+ *(((void **)orArray)-1 ) = 0 ;
459
+ }
454
460
}
455
461
else
456
462
{
457
463
orDummyObject = (Object*)((size_t )orArray + totalSize);
464
+ if (flags & GC_ALLOC_ZEROING_OPTIONAL)
465
+ {
466
+ // clean the syncblock of the dummy object.
467
+ *(((void **)orDummyObject)-1 ) = 0 ;
468
+ }
458
469
}
459
470
_ASSERTE (((size_t )orArray % sizeof (double )) == 0 );
460
471
orDummyObject->SetMethodTable (g_pObjectClass);
0 commit comments