Fix explicit layout validator memory alloc problems (#56757)
authorDavid Wrighton <davidwr@microsoft.com>
Wed, 4 Aug 2021 18:57:03 +0000 (11:57 -0700)
committerGitHub <noreply@github.com>
Wed, 4 Aug 2021 18:57:03 +0000 (11:57 -0700)
commit9d9aed68df99a4dd4c65b513f76bea1fd5a7b286
tree981402ea5592b04ee644e1b31ad564388d2bf1e1
parent37e9d4b1b491f6fd28a7d10df5dcaf49adcf71e9
Fix explicit layout validator memory alloc problems (#56757)

The ExplicitLayoutValidator currently used an array of bytes one to one with the size of the layout of the class. However, we have some test cases for outrageously large explicit layout structures and classes which cause this approach to OOM in crossgen2.

The fix is to move to a data structure defined in terms of intervals. This is probably a bit slower, but it requires vastly less memory for pathological situations.

Fixes #55164
Fixes #53559
src/coreclr/tools/Common/TypeSystem/Common/ExplicitLayoutValidator.cs