[Bug 877] New: HUSH: parse error in "echo a | if true; then cat ; fi" leads to out of memory

bugzilla at busybox.net bugzilla at busybox.net
Tue Jan 12 11:37:10 UTC 2010


https://bugs.busybox.net/show_bug.cgi?id=877

           Summary: HUSH: parse error in "echo a | if true; then cat ; fi"
                    leads to out of memory
           Product: Busybox
           Version: 1.15.x
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: m.garai at ziv.es
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


Architecture: blackfin (i think it just happens with NOMMU)

NOTE: this error does not happen with MMU compilations. But it can be forced
even in pc compilation by defining the constant BUILD_AS_NOMMU to 1, at least
It happens to me consistently.

if you try to execute one of the following example commands (i guess it happens
with every command that have an [if|while|..] after a pipe) hush uses all the
system's memory:

echo echo | while read a ; do true ; done
echo echo | while test `date +%s` -lt 9739378 ; do true; done
echo echo | while test 1 -gt 2 ; do true; done
echo a | if true; then echo a ; fi

In those cases the workaround for scripts is very simple, putting brackets in
the right part:

echo echo | ( while read a ; do true ; done )
echo echo | ( while test `date +%s` -lt 9739378 ; do true; done )
echo echo | ( while test 1 -gt 2 ; do true; done )
echo a | ( if true; then echo a ; fi )

I did try to find the bug myself and just couldn't, but I know at very high
level what is the error that is happening. When parsing and executing list of
commands hush (at least without MMU) executes itself again with -c argument and
the command fragments to be executed, for example "(echo a; echo b) | cat"
execute another hush process with "echo a; echo b" command. The issue here is
that with "echo a | if true; then echo a; fi" style commands it executes
infinite instances of hush with that entire command ("echo a | if true; then
echo a; fi" in this case) instead of a subcommand (that in this case I'm
guessing is "if true; then echo a; fi" )

Sorry for not finding the bug, and just tell me if you need more information.

thanks,

Mikel Garai


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list