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

__memcpy crash with [NSData -getBytes:range:]


  • Subject: __memcpy crash with [NSData -getBytes:range:]
  • From: Daniel Kennett <email@hidden>
  • Date: Fri, 10 Oct 2008 10:48:31 +0100

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

Thread 6 Crashed:
0 <<00000000>> 0xffff0d3f __memcpy + 1439 (cpu_capabilities.h:228)
1 com.apple.Foundation 0x9282e456 -[NSConcreteData getBytes:range:] + 267


I don't think it's the file that the NSData is created from - indeed, the customer sent me a copy of the file in question and it works perfectly on my machine. Any help in debugging this would be greatly appreciated! Surrounding the code in a @try block doesn't help - it still ends up with a hard crash (which is what I was expecting, given that is a EXC_BAD_ACCESS).

 Thanks,

-- Daniel

 _______________________

   email@hidden
   http://www.kennettnet.co.uk

Please include previous messages in any reply you send.



_______________________________________________

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


  • Follow-Ups:
    • Re: __memcpy crash with [NSData -getBytes:range:]
      • From: "Clark Cox" <email@hidden>
    • Re: __memcpy crash with [NSData -getBytes:range:]
      • From: Matt Gough <email@hidden>
  • Prev by Date: Re: Strategy for naming support folder
  • Next by Date: Re: Finder Crashes on File Open
  • Previous by thread: Re: KVC Question
  • Next by thread: Re: __memcpy crash with [NSData -getBytes:range:]
  • Index(es):
    • Date
    • Thread