* [PATCH] ipa-param-manip: Be careful about a reallocating hash_map (PR 103449)
@ 2021-11-29 18:17 Martin Jambor
2021-11-29 18:19 ` Jan Hubicka
0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2021-11-29 18:17 UTC (permalink / raw)
To: GCC Patches; +Cc: Jan Hubicka
Hi,
PR 103449 revealed that when I was storing result of one hash_map
lookup into another entry in the hash_map, I was still accessing the
entry in the table, which meanwhile could get reallocated, making the
accesses invalid-after-free.
Fixed with the following, which also simplifies the return statement
which must have been true even now.
Bootstrapped and tested on x86_64-linux. OK for master?
Thanks,
Martin
gcc/ChangeLog:
2021-11-29 Martin Liska <mliska@suse.cz>
Martin Jambor <mjambor@suse.cz>
PR ipa/103449
* ipa-param-manipulation.c
(ipa_param_body_adjustments::prepare_debug_expressions): Be
careful about hash_map reallocating itself. Simpify a return
which always returns true.
---
gcc/ipa-param-manipulation.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 479c20b3871..163af94cde0 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -1279,9 +1279,10 @@ ipa_param_body_adjustments::prepare_debug_expressions (tree dead_ssa)
if (gimple_assign_copy_p (def)
&& TREE_CODE (gimple_assign_rhs1 (def)) == SSA_NAME)
{
- tree *d = m_dead_ssa_debug_equiv.get (gimple_assign_rhs1 (def));
- m_dead_ssa_debug_equiv.put (dead_ssa, *d);
- return (*d != NULL_TREE);
+ tree d = *m_dead_ssa_debug_equiv.get (gimple_assign_rhs1 (def));
+ gcc_assert (d);
+ m_dead_ssa_debug_equiv.put (dead_ssa, d);
+ return true;
}
tree val
--
2.33.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ipa-param-manip: Be careful about a reallocating hash_map (PR 103449)
2021-11-29 18:17 [PATCH] ipa-param-manip: Be careful about a reallocating hash_map (PR 103449) Martin Jambor
@ 2021-11-29 18:19 ` Jan Hubicka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2021-11-29 18:19 UTC (permalink / raw)
To: Martin Jambor; +Cc: GCC Patches
> Hi,
>
> PR 103449 revealed that when I was storing result of one hash_map
> lookup into another entry in the hash_map, I was still accessing the
> entry in the table, which meanwhile could get reallocated, making the
> accesses invalid-after-free.
>
> Fixed with the following, which also simplifies the return statement
> which must have been true even now.
>
> Bootstrapped and tested on x86_64-linux. OK for master?
>
> Thanks,
>
> Martin
>
>
> gcc/ChangeLog:
>
> 2021-11-29 Martin Liska <mliska@suse.cz>
> Martin Jambor <mjambor@suse.cz>
>
> PR ipa/103449
> * ipa-param-manipulation.c
> (ipa_param_body_adjustments::prepare_debug_expressions): Be
> careful about hash_map reallocating itself. Simpify a return
> which always returns true.
OK, thanks!
Honza
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-29 18:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 18:17 [PATCH] ipa-param-manip: Be careful about a reallocating hash_map (PR 103449) Martin Jambor
2021-11-29 18:19 ` Jan Hubicka
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).