Skip to content

Commit e09e4a7

Browse files
committed
[Runtime] Check that extraDataSize matches extraDataPattern.
To prevent rdar://problem/68997282 from regressing, verify at runtime in debug builds that in calls to swift_allocateGenericValueMetadata the extraDataSize argument matches the OffsetInWords and SizeInWords specified by the GenericMetadataPartialPattern available within the pattern argument.
1 parent 8b6ff9c commit e09e4a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ swift::swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description
665665
"enum metadata header unexpectedly has extra members");
666666
static_assert(sizeof(EnumMetadata) == sizeof(ValueMetadata),
667667
"enum metadata unexpectedly has extra members");
668+
assert(!pattern->hasExtraDataPattern() ||
669+
(extraDataSize == (pattern->getExtraDataPattern()->OffsetInWords +
670+
pattern->getExtraDataPattern()->SizeInWords) *
671+
sizeof(void *)));
668672

669673
size_t totalSize = sizeof(FullMetadata<ValueMetadata>) + extraDataSize;
670674

0 commit comments

Comments
 (0)