Re: NSData, CFData maximum length question

2012-03-22 Thread Seth Willits
On Mar 21, 2012, at 10:49 PM, Seth Willits wrote:

 On Mar 21, 2012, at 6:00 PM, Grandinetti Philip wrote:
 
 I am confused about different behavior I'm seeing with CFData and NSData.
 If I create a new project in XCode 4.3.1 as a Core Foundation command line 
 tool, and enter the code below…
 
 You've triggered a bug!
 
 And it took me a long time, but I found it. The bug is in 
 __CFDataRoundUpCapacity, and has to do with a bad (1  ….) which should be 
 (1L  …).
 
 
 I'll file a report.


Filed as 11097403. And yeah, setting the length to anything  0 when the data 
is created will avoid the bug because the CFData is not  growable, and 
CFDataSetLength is handled a little different for growable CFDatas vs 
fixed-length mutable ones.

I'm not sure what [NSMutableData dataWithCapacity:0] does, but it's not a 
simple call to CFDataCreateMutable(kCFAllocatorDefault, 0) which is why it 
behaves differently as well. 


--
Seth Willits


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSData, CFData maximum length question

2012-03-22 Thread Wade Tregaskis
 I'm not sure what [NSMutableData dataWithCapacity:0] does, but it's not a 
 simple call to CFDataCreateMutable(kCFAllocatorDefault, 0) which is why it 
 behaves differently as well.

It probably ignores the specified capacity, for a start.  NSMutableDictionary 
does for its equivalent method, as does NSMutableArray IIRC.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSData, CFData maximum length question

2012-03-21 Thread Jens Alfke

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 = 0x8000 … 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

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSData, CFData maximum length question

2012-03-21 Thread Grandinetti Philip
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 = 0x8000 … 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSData, CFData maximum length question

2012-03-21 Thread Seth Willits
On Mar 21, 2012, at 6:00 PM, Grandinetti Philip wrote:

 I am confused about different behavior I'm seeing with CFData and NSData.
 If I create a new project in XCode 4.3.1 as a Core Foundation command line 
 tool, and enter the code below…

You've triggered a bug!

And it took me a long time, but I found it. The bug is in 
__CFDataRoundUpCapacity, and has to do with a bad (1  ….) which should be (1L 
 …).


I'll file a report.


--
Seth Willits

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com