[PATCH] top: fix double free causing a SIGABRT storm after SIGPIPE

Denys Vlasenko vda.linux at googlemail.com
Sat Aug 20 15:15:56 UTC 2016


On Fri, Aug 19, 2016 at 10:21 PM, Rob Landley <rob at landley.net> wrote:
> On 08/19/2016 01:30 PM, Denys Vlasenko wrote:
>> On Fri, Aug 19, 2016 at 8:17 PM, Rob Landley <rob at landley.net> wrote:
>>> On 08/19/2016 04:10 AM, Denys Vlasenko wrote:
>>>> +       if (ENABLE_FEATURE_CLEAN_UP) {
>>>> +               clearmems();
>>>> +#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
>>>> +               free(prev_hist);
>>>> +#endif
>>>> +       }
>>>
>>> The point of the ENABLE macros was so that you can go:
>>>
>>>   if (ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE)
>>>     free(prev_hist);
>>>
>>> Instead of the #ifdef forest. #ifdef CONFIG_FEATURE_BLAH already existed...
>>
>> Indeed ifders are ugly.
>> In this case, prev_hist does not exist if
>> !ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE:
>>
>> rocps/top.c:195:28: error: ‘struct globals’ has no member named ‘prev_hist’
>>  #define prev_hist        (G.prev_hist         )
>>                             ^
>> procps/top.c:1258:9: note: in expansion of macro ‘prev_hist’
>>     free(prev_hist);
>>          ^~~~~~~~~
>
> You're right, this entire file is an #ifdef forest.


It was worse :)
Sometime ago I selected a few opts which had minimal effect on code size
and nuked those.


More information about the busybox mailing list