From: Richard Biener <richard.guenther@gmail.com>
To: Keef Aragon <keef.aragon@konscious.net>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Jonathan Wakely <jwakely@redhat.com>
Subject: Re: [PATCH] bug in emergency cxa pool free()
Date: Wed, 17 Aug 2022 08:45:04 +0200 [thread overview]
Message-ID: <CAFiYyc14BAE78jdWfsHivuNNM9T12Gs_bfZh=3ZjPo0ydxqSxQ@mail.gmail.com> (raw)
In-Reply-To: <CAGejDpB0W4MBzV5kQ5QUpMGvwdVbMy7gp1r_M-wEUkR7Ysw_=Q@mail.gmail.com>
On Tue, Aug 16, 2022 at 9:15 PM Keef Aragon <keef.aragon@konscious.net> wrote:
>
> This probably has never actually affected anyone in practice. The normal
> ABI implementation just uses malloc and only falls back to the pool on
> malloc failure. But if that happens a bunch of times the freelist gets out
> of order which violates some of the invariants of the freelist (as well as
> the comments that follow the bug). The bug is just a comparison reversal
> when traversing the freelist in the case where the pointer being returned
> to the pool is after the existing freelist.
>
> I'm not sure what to do as far as the test suite is concerned. It's a
> private part of the implementation of the exception handling ABI and it can
> only ever be triggered if malloc fails (repeatedly). So it seems like
> reproducing it from the external interface will require hooking malloc to
> forcibly return NULL.
>
> But I'm a newb on these lists, so will obediently do as instructed.
Oops, that's my fault.
For consistency it's probably best written
as reinterpret_cast <char *> (e) + sz > reinterpret_cast <char *> ((*fe))
thus
diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc
b/libstdc++-v3/libsupc++/eh_alloc.cc
index c85b9aed40b..68f319869f9 100644
--- a/libstdc++-v3/libsupc++/eh_alloc.cc
+++ b/libstdc++-v3/libsupc++/eh_alloc.cc
@@ -224,8 +224,8 @@ namespace
free_entry **fe;
for (fe = &first_free_entry;
(*fe)->next
- && (reinterpret_cast <char *> ((*fe)->next)
- > reinterpret_cast <char *> (e) + sz);
+ && (reinterpret_cast <char *> (e) + sz
+ > reinterpret_cast <char *> ((*fe)->next));
fe = &(*fe)->next)
;
// If we can merge the next block into us do so and continue
The change is OK with that adjustment. I see you do not have write access so
I'll test & push it for you.
I'm curious how you noticed?
Thanks,
Richard.
next prev parent reply other threads:[~2022-08-17 6:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 19:14 Keef Aragon
2022-08-17 6:45 ` Richard Biener [this message]
2022-08-17 19:02 ` Keef Aragon
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='CAFiYyc14BAE78jdWfsHivuNNM9T12Gs_bfZh=3ZjPo0ydxqSxQ@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=keef.aragon@konscious.net \
--cc=libstdc++@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: link
Be 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).