ash parse tree and stack boundaries
Alexander Shishkin
virtuoso at slind.org
Mon Nov 29 13:47:45 UTC 2010
Hi,
There's a problem in busybox ash, which is running out of stack when parsing
very long input (funnily same bug also exists in bash), like
$ for i in $(seq 100000); do echo -n ":;"; done | busybox sh
Segmentation fault
which happens in evaltree() calling itself for each ":" node. Now, I'm
thinking of how to go about solving it.
1) introduce recursion depth counter to all the eval*() functions; stack
limits might differ, thus calculating the maximum depth might be tricky
and error prone;
2) install a SEGV handler; ugly;
3) optimise evaltree() to iterate through similar nodes; won't help against
large amounts of ":&&:;";
4) try to optimise the whole parser to get rid of recursion entirely;
5) switch to hush and be done with it (how good is it for a drop-in ash
replacement)?
Regards,
--
Alex
More information about the busybox
mailing list