> It looks like that:
> - (id) initWithArray: (NSArray*)array
> {
>   unsigned    c = [array count];
>   id        objects[c];
> 
>   [array getObjects: objects];
>   self = [self initWithObjects: objects count: c];
>   return self;
> }
> 
> with
> id objects[c];
> gcc allocates space on the stack  for c elements using alloca().
> On windows stacksize is limited. So at present when calling initWithArray
> with an array containing more then ~52100 elements stack runs out of space
> and applications crashes (or behaves really silly, depending what gets 
> overwritten)
> 
> The solution here to fix this would be to replace all that dynamic array stuff
> with malloc()/free() calls.

But alloca is much quicker!  We don't want to loose that speed for small
arrays.  I think the solution is:

 if (c < 100)
   use alloca as in the current code
 else
   use malloc()/free() as you suggest

(replace 100 with another reasonable default if you want).

Btw I already met this bug and I'm sure I had fixed it ... I must have
forgotten to commit the patch.



_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to