[PATCH 2/2] ash: use alloca to get rid of setjmp

Sam Liddicott sam at liddicott.com
Thu Jul 2 06:46:17 UTC 2015


On 1 Jul 2015 19:36, "Rich Felker" <dalias at libc.org> wrote:
>
> On Wed, Jul 01, 2015 at 04:46:18PM +0100, Ron Yorston wrote:
> > Now that the only thing protected by setjmp/longjmp is the saved string,
> > we can allocate it on the stack to get rid of the jump.
> >
> > Based on commit bd35d8e from git://
git.kernel.org/pub/scm/utils/dash/dash.git
> > by Herbert Xu.
>
> In general alloca is unsafe. It's not obvious to me what the code here
> is doing, so I can't tell for sure if it's safe or not, but I think
> this needs a strong justification of safety before being acceptable.

If you are allocating small amounts of memory then allocated is as safe as
calling a function - i.e. marginally increases the chance of stack overflow
by moving the stack pointer closer to it's limit.

Compare the size of the allocated to the saving of not needing the other
stack based variables, including jmploc.

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20150702/c4f9b71f/attachment.html>


More information about the busybox mailing list