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

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


On 08/01/2017 03:46 PM, Richard Biener wrote:
> On Tue, Aug 1, 2017 at 2:02 PM, Martin Liška <mliska@suse.cz> wrote:
>> 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?
> 
> Sure, go ahead now.

Thanks, installed to trunk as r250780. And I've just triggered tests on GCC-7 branch,
will install there as soon as it finishes.

Martin

> 
> Thanks,
> Richard.
> 
>> 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