[Toybox] [PATCH 2] Fix segfault in config2help

Patrick Oppenlander patrick.oppenlander at gmail.com
Tue Sep 26 19:00:34 PDT 2017


On Wed, Sep 27, 2017 at 11:36 AM, Rob Landley <rob at landley.net> wrote:
> But only on a system with all the package upgrades applied, installing
> straight from DVD ditn't reproduce it. I've een very slowly debugging it
> under a qemu instance (which takes like 15 seconds to pull up "vi" on a
> file, for some reason arch linux's gui is REALLY slow under qemu).

Instead of using qemu you could run it under valgrind or try gcc's
address sanitizer. I just checked and valgrind identifies both of
these as "use after free" problems.

> Either gcc or the libc (or ld, or...) got upgraded recently and started
> Doing A Thing.

I observed the same behaviour -- this started after a system update.

>> I haven't had time to completely track down the reason for this, but it
>> seems that under some conditions sym->help is left dangling after memory
>> is free'd by:
>>
>>         // Append trailing lines.
>>         while (tfrom) dlist_add(&anchor, dlist_zap(&tfrom));
>>
>> Either way, testing sym->enabled appears to fix the problem.
>
> That's a workaround, not a fix. And it means we'd need to rebuild
> generated/help.h every time .config changes (which right now we don't).

True.

> Lemme look at your other patch more closely, that's probably the start
> of the right fix...

There may be a better solution than strdup'ing the name. That was the
easiest fix to get it going again.

Patrick



More information about the Toybox mailing list