Skip to content

Commit 102e8a1

Browse files
committed
[Runtime] In debug builds, dirty metadata records.
To facilitate debugging metadata records which are not properly initialized, upon allocation fill them with a regular byte pattern (0xAA) so that on subsequent inspection it is obvious if part of the record is not initialized.
1 parent ba1caec commit 102e8a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ swift::swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description
663663

664664
auto bytes = (char*) cache.getAllocator().Allocate(totalSize, alignof(void*));
665665

666+
#ifndef NDEBUG
667+
// Fill the metadata record with garbage.
668+
memset(bytes, 0xAA, totalSize);
669+
#endif
670+
666671
auto addressPoint = bytes + sizeof(ValueMetadata::HeaderType);
667672
auto metadata = reinterpret_cast<ValueMetadata *>(addressPoint);
668673

0 commit comments

Comments
 (0)