Exc_Bad_Access Error When Trying to Change Bool Property

EXC_BAD_ACCESS when assigning a simple bool

BOOL is not an object type, it's a primitive (scalar). You don't need pointers to it. Change

@property (assign) BOOL *editMode;

into

@property (assign) BOOL editMode;

and also change

*addViewController.editMode=YES;

to

addViewController.editMode=YES;

and please read a tutorial on C pointers.

EXC_BAD_ACCESS error when trying to access class variables sent from function

I realized that my mistake was within my cellForRowAtIndexPath method. The problem was that in addition to calling the delegate method when the button was tapped (through an IBAction in my custom cell class), I also had the following line in the cellForRowAtIndexPath method:

cell1.followButton.addTarget(self, action: "follow:", forControlEvents: .TouchUpInside)

I imagine the bad access was occurring because somehow the same "follow" method was being called, but from inside the main view controller which means the sender cell was never passed as a parameter.

EXC_BAD_ACCESS at lauch for EAGLContext renderbufferStorage: fromDrawable: in Cocos2d app whie debugging

Looks like this is an issue on certain devices on iOS 8.3+. It works for me on almost all devices but the iPad mini 2 fails for me as well. The short of it is that there's nothing wrong with the call itself. Seems to be an Xcode bug with those devices for some reason. You can get around it (until Apple fixes it) by:

In Xcode, go to Product -> Scheme -> Edit Scheme ...
And for the Run Debug configuration (on left side) choose "Options" (on right side) and configure "GPU Frame Capture" as Disabled.

For more information, check out this thread:
https://github.com/BradLarson/GPUImage/issues/2022#issuecomment-118943746

EXC_BAD_ACCESS when trying to pass and read UnsafeMutableRawPointer through VTDecompressionSessionDecodeFrame

Ended up getting this working by using the following:

Input to VTDecompressionSessionDecodeFrame 's frameRefCon:

let nsString = NSString(string: "Anything")
let frameRefCon = Unmanaged.passRetained(nsString).toOpaque()

Making sure to pass frameRefCon and not &frameRefCon

On the output callback which has a param of sourceFrameRefCon: UnsafeMutableRawPointer?:

if let sourceFrameRefCon = sourceFrameRefCon {
let nsString = Unmanaged<NSString>.fromOpaque(sourceFrameRefCon).takeRetainedValue()
print(nsString)
}

EXC_BAD_ACCESS within main() with ARC but no hint on the error

There are still ways to get EXC_BAD_ACCESS with ARC. Some that I ran into

  1. If you are doing something where you make an object and it asynchronously calls you back -- you have to make sure to keep a reference to it somewhere or ARC will release it. An example is the UIImagePicker -- you can't just make a local image picker variable and call it (and then release it when it calls you back) -- you have to make a property and hold onto it

  2. If you don't always use properties to hold onto it, you might run into trouble -- ARC is using the presence of strong and weak to know what to do -- if you use an ivar instead, you might fool ARC (not 100% sure of this). One easy way to make sure you don't do this is to use @synthesize var = _var instead of letting the property and ivar have the same name. This way, if you forget self.var = obj and just use var = obj it will complain.

  3. I ran into a bug in gestures and tabs -- the tab views didn't retain the gestures added by IB -- I documented it here

Crash when using gesture recognizers in StoryBoard

In these cases Zombies should help -- so it not helping means that you are probably not prematurely causing a release to happen. More likely you are munging memory -- I would check all casts and anywhere you are using built-in arrays or non-object pointers to make sure you aren't going out of bounds. Guard Malloc can help

https://developer.apple.com/library/ios/#documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html

Set NSObject property - EXC_BAD_ACCESS


  • Verify that [dict objectForKey:@"infos"] is not NSNull - Crash
    can be here.
  • Other code looks OK.
  • Also add -(void)deallocto your object and put a
    break point there to verify that the object is not being released
    before the assignment.


Related Topics



Leave a reply



Submit