From: "Marc Nieper-Wißkirchen" <marc@nieper-wisskirchen.de>
To: David Malcolm <dmalcolm@redhat.com>
Cc: gcc-patches@gcc.gnu.org,
"Marc Nieper-Wißkirchen via Jit" <jit@gcc.gnu.org>
Subject: Re: [PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854]
Date: Sat, 8 Jan 2022 11:07:51 +0100 [thread overview]
Message-ID: <CAEYrNrRBSv31+nBrZAYhFVe4Ox5--pkLu-mKRUhzhQ=DUe5+aw@mail.gmail.com> (raw)
In-Reply-To: <2a54fac9b37d87afb009b8eb339d5ad6927454dd.camel@redhat.com>
Thanks for replying so quickly!
Am Do., 6. Jan. 2022 um 14:53 Uhr schrieb David Malcolm <dmalcolm@redhat.com>:
[...]
> Thanks for the patch.
>
> It looks correct to me, given that pass_manager::register_pass_name
> does an xstrdup and puts the result in the map.
>
> That said:
> - I'm not officially a reviewer for this part of gcc (though I probably
> touched this code last)
I am a newcomer to the codebase of GCC and haven't yet been able to
figure out whom to contact. I bothered you because the patch is mostly
relevant for the libgccjit frontend.
> - is it cleaner to instead change m_name_to_pass_map's key type from
> const char * to char *, to convey that the map "owns" the name? That
> way we probably wouldn't need struct typed_const_free_remove, and (I
> hope) works better with the type system.
The problem with that approach is that we would then need a new
version of string_hash in hash-traits.h, say owned_string_hash, which
derives from pointer_hash <char> and not pointer_hash <const char>.
This would add roughly as much code as struct typed_const_free_remove.
Using the hypothetical owned_string_hash in the definition of
m_name_to_pass_map in passes.c would then produce a map taking "char
*" strings instead of "const char *" strings. This, however, would
then lead to problems in pass_manager::register_pass_name where name
is a "const char *" string (coming from outside) but
m_name_to_pass_map->get would take a "char *" string.
I don't see how to resolve this without bigger refactoring, so I think
my struct typed_const_free_remove approach is less intrusive. This
conveys at least that the key isn't changed by the hashmap operations
and that it is yet owned (because this is something that
typed_const_free_remove presupposes.
Thanks,
Marc
[...]
next prev parent reply other threads:[~2022-01-08 10:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-19 21:30 Marc Nieper-Wißkirchen
2022-01-06 13:53 ` David Malcolm
2022-01-06 13:57 ` David Malcolm
2022-01-08 9:26 ` Marc Nieper-Wißkirchen
2022-01-08 10:07 ` Marc Nieper-Wißkirchen [this message]
2022-01-08 16:32 ` Jeff Law
2022-01-15 13:56 ` Marc Nieper-Wißkirchen
2022-01-23 13:18 ` Marc Nieper-Wißkirchen
2022-01-31 11:42 ` Marc Nieper-Wißkirchen
2022-03-11 16:31 ` Marc Nieper-Wißkirchen
2022-03-19 17:43 ` Jeff Law
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='CAEYrNrRBSv31+nBrZAYhFVe4Ox5--pkLu-mKRUhzhQ=DUe5+aw@mail.gmail.com' \
--to=marc@nieper-wisskirchen.de \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@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).