[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArray: Problem allocating memory on stack on windows

From: Roland Schwingel
Subject: NSArray: Problem allocating memory on stack on windows
Date: Thu, 09 Oct 2003 12:09:52 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624


There is a problem with all the -initWithArray: and related methods.

eg -initWithArray:
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;

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.

Attached with this email you will find a patch to current NSArray.m for fixing
all these problems in NSArray.


Attachment: NSArray.patch.gz
Description: GNU Zip compressed data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]