• 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: __memcpy crash with [NSData -getBytes:range:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __memcpy crash with [NSData -getBytes:range:]


  • Subject: Re: __memcpy crash with [NSData -getBytes:range:]
  • From: "Clark Cox" <email@hidden>
  • Date: Fri, 10 Oct 2008 08:09:12 -0700

On Fri, Oct 10, 2008 at 2:48 AM, Daniel Kennett <email@hidden> wrote:
> Hi list,
>
> I'm having trouble reproducing (and fixing) a rare bug that I sometimes get
> reports about.
>
> Here's the code that causes the crash. streamPosition and length are checked
> to make sure they're within the range of the NSData object:
>
> // Allocate a buffer.
> void *buffer = malloc(length);
>
> // Fill the buffer with the requested bytes.
> [_data getBytes:buffer range:NSMakeRange(streamPosition, length)];
>
> Very occasionally, this fails with this crash:
>
> Exception:  EXC_BAD_ACCESS (0x0001)
> Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Since the address above is 0x00000000, I suspect that buffer is NULL.
Are you checking malloc's return value? You may be exceeding your
process' 4GB address space.

--
Clark S. Cox III
email@hidden
_______________________________________________

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: 
 >__memcpy crash with [NSData -getBytes:range:] (From: Daniel Kennett <email@hidden>)

  • Prev by Date: Re: How a Controller in MainMenu.xib can send actions to a document object
  • Next by Date: Fwd: Finder Crashes on File Open
  • Previous by thread: Re: __memcpy crash with [NSData -getBytes:range:]
  • Next by thread: Key filtering in the NSSavePanel?
  • Index(es):
    • Date
    • Thread