[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unsigned int for loop in bash
From: |
Chet Ramey |
Subject: |
Re: unsigned int for loop in bash |
Date: |
Sun, 02 Feb 2014 16:09:52 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 2/1/14, 11:36 AM, Mathieu Malaterre wrote:
> As reported at:
>
> http://stackoverflow.com/questions/21500367/bash-for-loop-with-unsigned-integer
>
> I am getting a weird behavior in bash. Would it be possible for the
> next release of bash to not get a SIGSEV ?
Well, you're attempting to use a ridiculous amount of memory, so no
solution is really going to be perfect. Bash-4.3 has a couple of things
to avoid calling abort(3) when allocation fails in this situation, but
what happens after that depends on your malloc implementation. Even
when bash calls free() on all the memory it allocates attempting the
expansion, that memory will only go back to the kernel under a small set of
circumstances, and some malloc implementations are much better at that
than others. You might find that there is not enough memory left to do
anything but exit.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/