You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
UBSAN fires `insufficient-object-size` when F14Table's single-chunk optimization allocates less than `sizeof(F14Chunk)` bytes, then calls member functions on the `Chunk*`. For example, `F14Chunk<unsigned int>` had `sizeof` = 64 bytes, but a 2-element table allocates only 24 bytes (16-byte header + 2×4-byte items).
Fix by removing the `rawItems_` member array from `F14Chunk` so that `sizeof(F14Chunk)` equals 16 (just the header: `tags_[14]` + `control_` + `outboundOverflowCount_`). Items are accessed via pointer arithmetic from `this + kItemsOffset` instead of through the member array. Multi-chunk tables use an explicit stride constant (`kChunkStride`, equal to the old `sizeof`) for chunk-to-chunk navigation.
This preserves the single-chunk memory optimization while making all member calls on `Chunk*` UBSAN-clean:
- Minimum real allocation = 16 + 2*sizeof(Item) >= 24 > 16 = sizeof(Chunk)
- Empty instance (F14EmptyTagVector) = 16 bytes = sizeof(Chunk)
- Multi-chunk allocations use kChunkStride * N (same total size)
Reviewed By: ilvokhin
Differential Revision: D94696039
fbshipit-source-id: 06ef5480be9a2fdf3f0beb1e2c87916667e72abe
0 commit comments