public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113476] New: [14 Regression] irange::maybe_resize leaks memory via IPA VRP Date: Thu, 18 Jan 2024 11:43:12 +0000 [thread overview] Message-ID: <bug-113476-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113476 Bug ID: 113476 Summary: [14 Regression] irange::maybe_resize leaks memory via IPA VRP Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- I see ==1854== 122,424 bytes in 3 blocks are possibly lost in loss record 1,365 of 1,373 ==1854== at 0x505A1DF: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1854== by 0x1B8AB58: irange::maybe_resize(int) (value-range.h:645) ==1854== by 0x1B7C7DF: irange::union_(vrange const&) (value-range.cc:1451) ==1854== by 0x1B1D777: Value_Range::union_(vrange const&) (value-range.h:705) ==1854== by 0x30355A4: ipcp_vr_lattice::meet_with_1(vrange const&) (ipa-cp.cc:1046) ==1854== by 0x3035508: ipcp_vr_lattice::meet_with(vrange const&) (ipa-cp.cc:1 where union_ does // At this point, the vector should have i ranges, none overlapping. // Now it simply needs to be copied, and if there are too many // ranges, merge some. We wont do any analysis as to what the // "best" merges are, simply combine the final ranges into one. maybe_resize (i / 2); and maybe_resize: inline void irange::maybe_resize (int needed) { if (!m_resizable || m_max_ranges == HARD_MAX_RANGES) return; if (needed > m_max_ranges) { m_max_ranges = HARD_MAX_RANGES; wide_int *newmem = new wide_int[m_max_ranges * 2]; unsigned n = num_pairs () * 2; for (unsigned i = 0; i < n; ++i) newmem[i] = m_base[i]; m_base = newmem; } that looks OK at first right but there's an irange CTOR inline irange::irange (wide_int *base, unsigned nranges, bool resizable) that might end up with unexpected m_base/m_max_ranges here. Testcase is dwarf2out.i preprocessed from the last release using C but I guess it's easy to reproduce with any TU from GCC itself.
next reply other threads:[~2024-01-18 11:43 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-18 11:43 rguenth at gcc dot gnu.org [this message] 2024-01-18 11:43 ` [Bug tree-optimization/113476] " rguenth at gcc dot gnu.org 2024-01-18 11:48 ` rguenth at gcc dot gnu.org 2024-01-18 11:50 ` rguenth at gcc dot gnu.org 2024-01-18 13:32 ` rguenth at gcc dot gnu.org 2024-01-22 17:48 ` jamborm at gcc dot gnu.org 2024-01-23 6:58 ` rguenth at gcc dot gnu.org 2024-02-19 15:05 ` jamborm at gcc dot gnu.org 2024-02-21 9:15 ` aldyh at gcc dot gnu.org 2024-02-21 9:17 ` aldyh at gcc dot gnu.org 2024-02-21 9:18 ` aldyh at gcc dot gnu.org 2024-02-21 9:19 ` aldyh at gcc dot gnu.org 2024-02-21 11:22 ` aldyh at gcc dot gnu.org 2024-02-21 11:25 ` jakub at gcc dot gnu.org 2024-02-21 11:55 ` aldyh at gcc dot gnu.org 2024-02-21 12:10 ` jakub at gcc dot gnu.org 2024-02-21 14:43 ` [Bug ipa/113476] " cvs-commit at gcc dot gnu.org 2024-02-21 14:44 ` jamborm at gcc dot gnu.org 2024-02-22 7:38 ` rguenther at suse dot de 2024-02-22 16:07 ` aldyh at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113476-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).