Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:53:18+00:00 2026-06-01T07:53:18+00:00

I have a piece of code of my application that’s I get the error

  • 0

I have a piece of code of my application that’s I get the error where I don’t have idea what’s the problem and this error occurs when I open the device camera and start to get capture frames. The weird thing here is, this works but gets the error below in a short or long time of the capture has started.

Error: “Thread 1: EXC_BAD_ACCESS (code=1, address=0xN)” where “N” is a hypothetical hex memory address.

The code:

- (void)imageToBuffer:(CMSampleBufferRef)source
{ 
  NSData *data;

  CVImageBufferRef buffer = CMSampleBufferGetImageBuffer(source);
  CVPixelBufferLockBaseAddress(buffer, 0);

  size_t bytesPerRow = CVPixelBufferGetBytesPerRow(buffer);
  size_t height = CVPixelBufferGetHeight(buffer);
  void *bufferSrc = CVPixelBufferGetBaseAddress(buffer);

  data = [NSData dataWithBytes:bufferSrc length:bytesPerRow * height];
  CVPixelBufferUnlockBaseAddress(buffer, 0);

  [self.delegate didReceivedFrame:data];
}

@end


#pragma mark - AVCaptureVideoDataOutputSampleBufferDelegate implementation
@implementation AVCaptureManager (AVCaptureVideoDataOutputSampleBufferDelegate)

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
  dispatch_async(dispatch_get_main_queue(), ^{
    [self imageToBuffer:sampleBuffer];
  });
}

This error normally occurs in the line:

CVPixelBufferLockBaseAddress(buffer, 0);

Any ideas? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:53:20+00:00Added an answer on June 1, 2026 at 7:53 am

    I would say the error is here:

    dispatch_async(dispatch_get_main_queue(), ^{
      [self imageToBuffer:sampleBuffer];
    });
    

    This call is dispatched asynchronously, and to my knowledge CMSampleBuffers don’t necessarily hold on to their contents (the data might be released before the sample buffer object).

    Make sure you dispatch it synchronously on the main queue.

    BTW: Why do you dispatch on the main thread in the first place?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that executes this piece of code (JQuery 1.4.2) in an
I have this piece of code in my application. I suspect that it is
I have this piece of code that has a problem. so can you help
I have a piece of code (below) that can get the text of an
I have written a piece of code that detects installed application in android and
I have a piece of Actionscript code that Implements MovieClip. I don't seem to
I have a piece of code in my application that retrieves the application certificate
I currently have a piece of code in my Android application that picks up
I have a simple piece of code in a .NET console application that tries
I have a piece of code in an ASP.NET application that builds a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.