hush - memory leak?

Denys Vlasenko vda.linux at googlemail.com
Tue Dec 28 22:11:26 UTC 2010


On Tuesday 28 December 2010 21:18, Piotr Grudzinski wrote:
> >> Here is my 'top' output (how would I get output formated like your's?)
> >
> > By pressing 's'
> 
> When I press 's', top terminates with the following message:
> top: no process info in /proc
> 
> > I would like you to try more things.
> > For example:
> >
> 
> Does "while true; do cat </dev/null; done" leak? - NO
> Does "while true; do echo -n ""; done" leak? - NO
> Does "while true; do cut </dev/null; done" leak? - YES
> Does "while true; do grep qwerty </dev/null; done" leak? -YES
> 
> >
> > Next experiment: find and set LEAK_HUNTING to 1 in hush.c:
> >
> > #define LEAK_HUNTING 1
> >
> > Build busybox, then run:
> >
> > # ./busybox hush -c 'i=1000; while test $((--i)) -ne 1; do sleep 0; done'
> > 2>output
> > # shell/hush_leaktool.sh
> >
> > Please do this test and send me your output.leaked file.
> 
> The output.leaked file is empty but my free mem went down from 10MB to 1MB.
> 
> I have noticed that if I change BUSYBOX_EXEC_PATH from /proc/self/exe to 
> /bin/busybox the problem is gone.
> The same problem is with bb 1.17.4 but I had BUSYBOX_EXEC_PATH set to 
> /bin/busybox so I didn't see it.

Can you compile the following test program:

#include <sys/types.h>
#include <unistd.h>
int main(int argc, char **argv)
{
    while (1) {
        write(1, ".", 1);
        execv("/proc/self/exe", argv);
    }
    return 0;
}

via "gcc -Wall testprog.c", run it and report whether you see
free memory disappearing?

-- 
vda


More information about the busybox mailing list