aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-02-21 21:59:40 +1030
committerAlan Modra <amodra@gmail.com>2024-02-21 23:40:12 +1030
commitf96127310144d360eac93444c1b6efe80497d163 (patch)
treeb8d17728ae0ea276d56d1228940ddf27e69461a8
parentf618d7fda20afe68c5c3979c4c1be40714e8e5a0 (diff)
downloadgdb-f96127310144d360eac93444c1b6efe80497d163.zip
gdb-f96127310144d360eac93444c1b6efe80497d163.tar.gz
gdb-f96127310144d360eac93444c1b6efe80497d163.tar.bz2
Re: PR29785, memory bloat after b43771b045fb
Commit 7bd1e04a3532 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.
-rw-r--r--bfd/dwarf2.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 8491257..5eda14e 100644
--- a/bfd/dwarf2.c
+++ b/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)