Re: [PATCH] Clean up dangling pointers in cgraph_edge (PR ipa/89330).

2019-07-30 Thread Martin Liška
On 7/30/19 10:36 AM, Richard Biener wrote:
> On Tue, Jul 30, 2019 at 9:27 AM Martin Liška  wrote:
>>
>> Hi.
>>
>> We have to clean up dangling pointers before we call ggc_free for a 
>> cgraph_edge.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>> And it survives --enable-checking=release bootstrap on x86_64-linux-gnu.
>>
>> Ready to be installed?
> 
> Eh?  The only "real" effect I see is that e->indirect_info test is now
> never true.

Yep, you are right.

> 
> I think it rather means the edge we ggc_free is still referenced to
> from somewhere
> and _that_ needs to be fixed or we ggc_free the edge wrongly.

Yes, that's one another situation IPA CP is touching a dead cgraph_edge.
Martin will help me latter.
I'm reducing a test-case now..

Martin

> 
> Richard.
> 
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2019-07-30  Martin Liska  
>>
>> PR ipa/89330
>> * cgraph.c (symbol_table::free_edge): Memset 0 to cgraph_edge
>> before we call ggc_free.
>> ---
>>  gcc/cgraph.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>>



Re: [PATCH] Clean up dangling pointers in cgraph_edge (PR ipa/89330).

2019-07-30 Thread Richard Biener
On Tue, Jul 30, 2019 at 9:27 AM Martin Liška  wrote:
>
> Hi.
>
> We have to clean up dangling pointers before we call ggc_free for a 
> cgraph_edge.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> And it survives --enable-checking=release bootstrap on x86_64-linux-gnu.
>
> Ready to be installed?

Eh?  The only "real" effect I see is that e->indirect_info test is now
never true.

I think it rather means the edge we ggc_free is still referenced to
from somewhere
and _that_ needs to be fixed or we ggc_free the edge wrongly.

Richard.

> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-07-30  Martin Liska  
>
> PR ipa/89330
> * cgraph.c (symbol_table::free_edge): Memset 0 to cgraph_edge
> before we call ggc_free.
> ---
>  gcc/cgraph.c | 2 ++
>  1 file changed, 2 insertions(+)
>
>


[PATCH] Clean up dangling pointers in cgraph_edge (PR ipa/89330).

2019-07-30 Thread Martin Liška
Hi.

We have to clean up dangling pointers before we call ggc_free for a cgraph_edge.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
And it survives --enable-checking=release bootstrap on x86_64-linux-gnu.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-07-30  Martin Liska  

PR ipa/89330
* cgraph.c (symbol_table::free_edge): Memset 0 to cgraph_edge
before we call ggc_free.
---
 gcc/cgraph.c | 2 ++
 1 file changed, 2 insertions(+)


diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 81250acb70c..372974f12df 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1008,6 +1008,8 @@ symbol_table::free_edge (cgraph_edge *e)
   if (e->m_summary_id != -1)
 edge_released_summary_ids.safe_push (e->m_summary_id);
 
+  /* Clear out the edge so we do not dangle pointers.  */
+  memset (e, 0, sizeof (*e));
   if (e->indirect_info)
 ggc_free (e->indirect_info);
   ggc_free (e);