-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] Pack extra data pattern structs. #34822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
@swift-ci please test asan |
@swift-ci please clean test windows platform |
@swift-ci please asan test |
Build failed |
ea93c3d
to
264dcf2
Compare
@swift-ci please test |
@swift-ci please asan test |
Build failed |
264dcf2
to
a39d916
Compare
@swift-ci please test |
@swift-ci please asan test |
1 similar comment
@swift-ci please asan test |
Build failed |
Build failed |
Previously, the extra data pattern structs for struct and enums were not packed. On 32 bit, this resulted in an extra data pattern struct which was 4 bytes too large whenever there was an odd number of fields in the struct. The result was writing past the end of the allocated struct. That bug only caused occasional crashes because (1) for the most part there was additional space beyond the end of the allocation intended for the struct metadata in the bump allocator and (2) while half of the trailing flags field would be overwritten, because those bits of the trailing flags being nonzero did not have an observable effect since those bits of the trailing flags field are not yet used. Here, the structs are marked packed, resulting in the appropriate size for the extra data pattern structs on 32 bit platforms. rdar://problem/68997282
To prevent the fix for rdar://problem/68997282 from regressing, assert that the size of the extra data patterns for generic enums and structs combined with the corresponding offsets matches the size passed from the generic metadata instantiation function to swift_allocateGenericValueMetadata.
@swift-ci please test |
a39d916
to
3b13850
Compare
@swift-ci please test |
@swift-ci please asan test |
Build failed |
Build failed |
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.
3b13850
to
e09e4a7
Compare
@swift-ci please test |
Previously, the extra data pattern structs for struct and enums were not packed.
On 32 bit, this resulted in an extra data pattern struct which was 4 bytes too large whenever there was an odd number of fields in the struct. The result was writing past the end of the allocated struct. That bug only caused occasional crashes because (1) for the most part there was additional space beyond the end of the allocation intended for the struct metadata in the bump allocator and (2) while half of the trailing flags field would be overwritten, those bits of the trailing flags being nonzero did not have an observable effect since those bits of the trailing flags field are not yet used.
Here, the structs are marked packed, resulting in the appropriate size for the extra data pattern structs on 32 bit platforms.
rdar://problem/68997282