*Re: PR29785, memory bloat after b43771b045fb@ 2024-02-21 13:09 Alan Modra0 siblings, 0 replies; only message in thread From: Alan Modra @ 2024-02-21 13:09 UTC (permalink / raw) To: binutils;+Cc:Steinar H. Gunderson 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. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 8491257aaaf..5eda14e1e7e 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) -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] only message in thread

only message in thread, other threads:[~2024-02-21 13:09 UTC | newest]Thread overview:(only message) (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-21 13:09 PR29785, memory bloat after b43771b045fb Alan Modra

This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).