mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
Re: PR29785, memory bloat after b43771b045
Commit 7bd1e04a35
introduced "dwarf2.c:2152:29: runtime error: shift
exponent 64 is too large". This is on the bucket_high_pc calculation
which was moved to the top of insert_arange_in_trie where previously
it was later, at a point where the overflow could not occur. Move it
back and arrange for a duplicate calculation of bucket_high_pc which
is also protected from overflow.
PR 29785
* dwarf2.c (insert_arange_in_trie): Split bucket_high_pc.
Move trie_pc_bits < VMA_BITS into splitting_leaf_will_help.
This commit is contained in:
parent
f618d7fda2
commit
f961273101
10
bfd/dwarf2.c
10
bfd/dwarf2.c
@ -2148,8 +2148,6 @@ insert_arange_in_trie (bfd *abfd,
|
||||
bfd_vma low_pc,
|
||||
bfd_vma high_pc)
|
||||
{
|
||||
bfd_vma bucket_high_pc =
|
||||
trie_pc + ((bfd_vma) -1 >> trie_pc_bits); /* Inclusive. */
|
||||
bfd_vma clamped_low_pc, clamped_high_pc;
|
||||
int ch, from_ch, to_ch;
|
||||
bool is_full_leaf = false;
|
||||
@ -2180,13 +2178,15 @@ insert_arange_in_trie (bfd *abfd,
|
||||
|
||||
is_full_leaf = leaf->num_stored_in_leaf == trie->num_room_in_leaf;
|
||||
|
||||
if (is_full_leaf)
|
||||
if (is_full_leaf && trie_pc_bits < VMA_BITS)
|
||||
{
|
||||
/* See if we have at least one leaf that does _not_ cover the
|
||||
entire bucket, so that splitting will actually reduce the number
|
||||
of elements in at least one of the child nodes. (For simplicity,
|
||||
we don't test the range we're inserting, but it will be counted
|
||||
on the next insertion where we're full, if any.) */
|
||||
bfd_vma bucket_high_pc =
|
||||
trie_pc + ((bfd_vma) -1 >> trie_pc_bits); /* Inclusive. */
|
||||
for (i = 0; i < leaf->num_stored_in_leaf; ++i)
|
||||
{
|
||||
if (leaf->ranges[i].low_pc > trie_pc
|
||||
@ -2201,7 +2201,7 @@ insert_arange_in_trie (bfd *abfd,
|
||||
|
||||
/* If we're a leaf with no more room and we're _not_ at the bottom,
|
||||
convert to an interior node. */
|
||||
if (is_full_leaf && splitting_leaf_will_help && trie_pc_bits < VMA_BITS)
|
||||
if (is_full_leaf && splitting_leaf_will_help)
|
||||
{
|
||||
const struct trie_leaf *leaf = (struct trie_leaf *) trie;
|
||||
unsigned int i;
|
||||
@ -2265,6 +2265,8 @@ insert_arange_in_trie (bfd *abfd,
|
||||
clamped_high_pc = high_pc;
|
||||
if (trie_pc_bits > 0)
|
||||
{
|
||||
bfd_vma bucket_high_pc =
|
||||
trie_pc + ((bfd_vma) -1 >> trie_pc_bits); /* Inclusive. */
|
||||
if (clamped_low_pc < trie_pc)
|
||||
clamped_low_pc = trie_pc;
|
||||
if (clamped_high_pc > bucket_high_pc)
|
||||
|
Loading…
Reference in New Issue
Block a user