[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a recursion bug
From: |
Dan Douglas |
Subject: |
Re: a recursion bug |
Date: |
Thu, 4 Oct 2012 10:47:45 -0500 |
It's possible to grow the parameter expansion stack forever too.
$ (x=x[\${!x}]<${!x})
Segmentation fault
One would think there would be no need to keep a stack if there are no
more expansions to the right of the current expansion.
On Wed, Oct 3, 2012 at 3:39 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> On 10/3/12 3:40 PM, Greg Wooledge wrote:
>> On Wed, Oct 03, 2012 at 01:23:58PM -0600, Bob Proulx wrote:
>>> But in any case, is there
>>> anything in there that is about bash? If so the we need an exact test
>>> case.
>>
>> You could start with this one:
>>
>> imadev:~$ bash-4.2.28 -c 'a() { echo "$1"; a $(($1+1)); }; a 1' 2>&1 | tail
>> Pid 4466 received a SIGSEGV for stack growth failure.
>> Possible causes: insufficient memory or swap space,
>> or stack size exceeded maxssiz.
>
> There's not actually anything you can do about that except use ulimit to
> get as much stack space as you can.
Well, poor-mans TCO
f()
if [ "$1" -ge 0 ]; then
printf "$1 "
exec dash -c "${2}f "'$(($1-1)) "$2"' -- "$@"
fi
( f 1000000 "$(typeset -f f)"$'\n' )
Joking of course :o)
FUNCNEST is usually good enough for me. No other shell I'm aware of
even has that.
--
Dan Douglas
- Re: a recursion bug, (continued)
- Re: a recursion bug, Greg Wooledge, 2012/10/02
- Re: a recursion bug, Linda Walsh, 2012/10/02
- Re: a recursion bug, Bob Proulx, 2012/10/02
- Re: a recursion bug, Steven W. Orr, 2012/10/02
- Re: a recursion bug, Linda A. Walsh, 2012/10/03
- Re: a recursion bug, Bob Proulx, 2012/10/03
- Re: a recursion bug, Greg Wooledge, 2012/10/03
- Re: a recursion bug, Chet Ramey, 2012/10/03
- Re: a recursion bug, Bob Proulx, 2012/10/03
- Re: a recursion bug, Chet Ramey, 2012/10/04
- Re: a recursion bug,
Dan Douglas <=
- Re: a recursion bug, Bob Proulx, 2012/10/03
- Re: a recursion bug, Eric Blake, 2012/10/03
RE: a recursion bug, Yuxiang Cao, 2012/10/03
Re: a recursion bug, Bob Proulx, 2012/10/02
Re: a recursion bug, Greg Wooledge, 2012/10/03