[Toybox] [landley/toybox] Fix memory leak in id found by LSan (#38)

Rob Landley rob at landley.net
Sat Jul 23 16:20:16 PDT 2016


Short-lived commands don't necessarily free their memory because exit()
will do it for them. We only worry about allocations building up,
perhaps based on size of input (one leak per line of sed or grep would
be bad if they're working on millions of lines of input), or based on
duration of running (leaking every 30 seconds in a server that runs days
would be bad). (Note that those allocations don't have to be _leaks_ to
be concerning.)

See the config symbol TOYBOX_FREE for details. (Config.in line 98 if you
don't want to deal with menuconfig).

Thanks,

Rob

On 07/23/2016 12:08 PM, Usishchev Yury wrote:
> Full LSan log:
> 
> |$ ./generated/unstripped/toybox id -u 1000
> =================================================================
> ==32119==ERROR: LeakSanitizer: detected memory leaks Direct leak of 80
> byte(s) in 1 object(s) allocated from: #0 0x7f331a5c3ab2 in malloc
> (/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/libasan.so.2+0x98ab2) #1
> 0x411b20 in xmalloc lib/xwrap.c:64 Indirect leak of 400 byte(s) in 5
> object(s) allocated from: #0 0x7f331a5c3ab2 in malloc
> (/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/libasan.so.2+0x98ab2) #1
> 0x411b20 in xmalloc lib/xwrap.c:64 SUMMARY: AddressSanitizer: 480
> byte(s) leaked in 6 allocation(s). |
> 
> ------------------------------------------------------------------------
> 
> 
>         You can view, comment on, or merge this pull request online at:
> 
>   https://github.com/landley/toybox/pull/38
> 
> 
>         Commit Summary
> 
>   * Fix memory leak in id found by LSan
> 
> 
>         File Changes
> 
>   * *M* toys/posix/id.c
>     <https://github.com/landley/toybox/pull/38/files#diff-0> (6)
> 
> 
>         Patch Links:
> 
>   * https://github.com/landley/toybox/pull/38.patch
>   * https://github.com/landley/toybox/pull/38.diff
> 
>> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/landley/toybox/pull/38>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABWXCbfYOKgr0YxEuki0g6OYoWNN-qqtks5qYkqWgaJpZM4JTZiU>.
> 



More information about the Toybox mailing list