No matter what the subshell limit is, wouldn't it be better to exit gracefully
with an error message like, "Too many subshells," when the limit is reached?

Terrence Doyle

On 9/18/12 10:00 AM, ольга крыжановская wrote:
> Make the counter ssize_t? The bad thing is that ksh is full of shorts,
> which should all be replaced with at least int32_t or uint32_t or some
> thing bigger.
>
> Of course, the next question is, do you want so many sub shells? If
> you do that do a shell which does fork() for a sub shell then you face
> 32000 fork() calls. ksh93 with it's COW approach to sub shells is just
> a lucky pick then.
>
> Olga
>
> On Tue, Sep 18, 2012 at 4:56 PM, Michal Hlavinka <mhlav...@redhat.com> wrote:
>> Hi,
>>
>> we found a bug in ksh. It uses only short size int for curenv (current
>> subshell number) and once it overflows, it crashes.
>>
>> Reproducer:
>> ===============================================
>> #!/bin/ksh
>>
>> main()
>> {
>>
>>  typeset i=0;
>>  typeset b="";
>>
>>   (while true
>>   do
>>     (b=$(printf %08d ${i}));
>>     (( i = ${i} + 1 ))
>>      echo $i;
>>   done)
>>   echo "count : ${i}";
>> }
>>
>> main "$@";
>> ===============================================
>>
>> ./test.sh
>> ...
>> ...
>> 32765
>> 32766
>> 32767
>> Segmentation fault
>>
>> Tested with ksh 2012-08-01. Let me know if you need more information.
>>
>> Michal
>> _______________________________________________
>> ast-developers mailing list
>> ast-developers@research.att.com
>> https://mailman.research.att.com/mailman/listinfo/ast-developers


_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to