@@ -434,7 +434,8 @@ OBJECTREF AllocateSzArray(MethodTable* pArrayMT, INT32 cElements, GC_ALLOC_FLAGS
434434 // dummy object.
435435 // If the GC gives us a 8 byte aligned address, we use it for the array and place the dummy
436436 // 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.
438439 //
439440 // Note: on 64 bit platforms, the GC always returns 8 byte aligned addresses, and we don't
440441 // execute this code because DATA_ALIGNMENT < sizeof(double) is false.
@@ -447,14 +448,24 @@ OBJECTREF AllocateSzArray(MethodTable* pArrayMT, INT32 cElements, GC_ALLOC_FLAGS
447448 orArray = (ArrayBase*)Alloc (totalSize + MIN_OBJECT_SIZE, flags);
448449
449450 Object* orDummyObject;
450- if ((size_t )orArray % sizeof (double ))
451+ if ((( size_t )orArray % sizeof (double )) != 0 )
451452 {
452453 orDummyObject = orArray;
453454 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+ }
454460 }
455461 else
456462 {
457463 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+ }
458469 }
459470 _ASSERTE (((size_t )orArray % sizeof (double )) == 0 );
460471 orDummyObject->SetMethodTable (g_pObjectClass);
0 commit comments