[Serialization] Add some asserts to catch giant method lists.

This would have allowed us to triage rdar://problem/28305755 much
sooner. The actual problem is pretty bad: if you have too many methods
with the same selector, serialization just falls over.  "Too many" is
in the thousands, which seems unlikely, but 'dealloc' can actually get
there if there are a lot of little classes, and 'init' might as well,
so we really should do better here.
This commit is contained in:
Jordan Rose
2016-10-06 14:07:04 -07:00
parent d5642f731b
commit 16c61bbbba
2 changed files with 12 additions and 3 deletions

View File

@@ -433,13 +433,15 @@ public:
static data_type ReadData(internal_key_type key, const uint8_t *data,
unsigned length) {
const constexpr auto recordSize = sizeof(uint32_t) + 1 + sizeof(uint32_t);
assert(length % recordSize == 0 && "invalid length");
data_type result;
while (length > 0) {
TypeID typeID = endian::readNext<uint32_t, little, unaligned>(data);
bool isInstanceMethod = *data++ != 0;
DeclID methodID = endian::readNext<uint32_t, little, unaligned>(data);
result.push_back(std::make_tuple(typeID, isInstanceMethod, methodID));
length -= sizeof(uint32_t) + 1 + sizeof(uint32_t);
length -= recordSize;
}
return result;