[PATCH] Fix segfault in gcov.c (PR gcov-profile/81561).

Martin Liška mliska@suse.cz
Tue Aug 1 12:02:00 GMT 2017


On 07/27/2017 01:48 PM, Richard Biener wrote:
> On Thu, Jul 27, 2017 at 12:12 PM, Martin Liška <mliska@suse.cz> wrote:
>> Hello.
>>
>> As reported in mentioned PR, we segfault in gcov tool when one uses -a. It's caused by fact
>> that vectors blocks and block_lists have indices kept in sync and as one removes an element
>> from blocks via:
>>     blocked.erase (it);
>>
>> Then calling recursively the same function breaks the synchronization. The patch was originally
>> written by Joshua (adding him to CC). If I'm correct calling:
>>
>> -    unblock (u, blocked, block_lists);
>>
>> does not make sense as we've already removed 'u'. Plus one needs to put content of block_lists[index]
>> to a separate vector in order to not to break iteration.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>> And fixed the problem reported in opensuse bugzilla (mentioned in the GCC bugzilla PR).
>>
>> Ready to be installed?
> 
> Looks good to me but please wait for Joshua to confirm.

Hello.

No reply yet, I've just verified that in the article the function (unblock) does the same as with the patch:
https://pdfs.semanticscholar.org/72c3/b54c1aea0a3193bad9721727a1798101ab26.pdf (page 3).

I would be happy to have the patch in 7.2.
Can we Richi catch the deadline?

Thanks,
Martin

> 
> Did you manage to extract a testcase?
> 
> Thanks,
> Richard.
> 
>> Martin
>>
>>
>> gcc/ChangeLog:
>>
>> 2017-07-26  Martin Liska  <mliska@suse.cz>
>>
>>          PR gcov-profile/81561
>>          * gcov.c (unblock): Make unblocking safe as we need to preserve
>>          index correspondence of blocks and block_lists.
>> ---
>>   gcc/gcov.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>>
>>



More information about the Gcc-patches mailing list