• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSData, CFData maximum length question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData, CFData maximum length question


  • Subject: Re: NSData, CFData maximum length question
  • From: Grandinetti Philip <email@hidden>
  • Date: Wed, 21 Mar 2012 23:13:16 -0400

Found something interesting.   If I simply set the capacity to "length" instead of 0, then it runs without crashing.   Could this be a bug in CFData?

int main(int argc, const char * argv[])
{
    CFIndex length = (1ULL << 30);
    fprintf(stderr, "length = %ld\n",length);
    CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, length);
    CFDataSetLength(data, length);
}

- Philip


On Mar 21, 2012, at 10:26 PM, Jens Alfke wrote:

>
> On Mar 21, 2012, at 6:00 PM, Grandinetti Philip wrote:
>
>> it crashes with the error message below:
>>
>> length = 1073741824
>> test(2463) malloc: *** mmap(size=18446744071562067968) failed (error code=12)
>
> That is bizarre — it happens to me too.
>
> 18446744071562067968 = 0xffffffff80000000 … so it’s as though something doubled the length parameter, then sign-extended it to 64 bits, before passing it to malloc. Why, I have no idea.
>
> —Jens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >NSData, CFData maximum length question (From: Grandinetti Philip <email@hidden>)

  • Prev by Date: Re: How to get max size of view according to constraints?
  • Next by Date: Re: Missing header files/folders?
  • Previous by thread: NSData, CFData maximum length question
  • Next by thread: Re: NSData, CFData maximum length question
  • Index(es):
    • Date
    • Thread