On 02/07/2017 04:17 PM, Jakub Jelinek wrote:
Hi!

As mentioned in the PR, on a huge function init_costs attempts to allocate
124 * 17380077 bytes, 124 is max_struct_costs_size and 17380077
is cost_elements_num.  The problem is that the multiplication is done in
int type, so it overflows and we attempt to allocate 0xffffffff8074aacc
bytes.  Other similar multiplications in ira-costs.c use size_t as type
of at least one operand, so it works properly.  The following patch
fixes it by making sure struct_costs_size and max_struct_costs_size have
size_t type.  The first hunk shouldn't result in more memory being used,
on 32-bit host it is not any change and the field is followed by
a pointer, so on 64-bit hosts there has been padding that we now use.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Sure, Jakub.

Reply via email to