objc_release EXC_BAD_ACCESS

2019-04-16 09:46发布

Unable to determine what is going on with this error.

I am uploading a file in multiple segments.

I have threaded my api calls into 7 concurrent threads.

Here is the assembly code that it stops at.

Assembly Code

Here is my printed stack trace

Printed Stack Trace

Finally the Stack window

Stack Window

I do not have any DISPATCH_QUEUE_PRIORITY_LOW except for a #define for dispatch_get_low() and I do not have any calls to dispatch_get_low()

as a little background, I am developing my app from xcode 4.4 and recently installed GM Seed 4.5 to test on ios 6. All of my code is still ios5 and this bug plagued me before and after the update of xcode.

UPDATE

After adding back NSZombieEnabled YES to my environment variables

NSZombieEnabled environment variable

I was presented with a different error in much the same fashion, This one however is called forwarding

Assembly breakpoint

Breakpoint Assembly

Stack Trace Printout

Stack Trace Printout

Call Stack Window

Call Stack Window

I am still at a loss as to what is actually going on.

I am still investigating. any further assistance will be much appreciated.

==== New Developments ====

Apparently while trying to get some output of the malloc calls. I completely alleviated the bug.

This is disheartening because I dont think I can compile for release with this flag enabled.

enter image description here

the EXC_BAD_ACCESS no longer appears, therefore the log is going to be useless. This bug is turning out to be the weirdest problem I have faced yet, And I have faced a lot of weird iOS bugs.

Update again

I have been tracking this error down. Turns out the object being a problem is a -[CFNumber release] call The number is being created in a block, then being passed down to the delegate.

It may also be combined with the Core Data object saving and then going away.

I have added a method HSLogBrute(@"") which logs the line number and filename.

I have tracked it down to the following code.

    if (progressMatch > progressPercent){
        HSLogBrute(@"");
        TransferStatus *transferStatus = [TransferStatus objectByID:task.transferStatusID];
        HSLogBrute(@"");
        transferStatus.segmentsTransferred = [NSNumber numberWithInt:segmentsTransferred.intValue];
        HSLogBrute(@"");
        transferStatus.segmentsTotal = [NSNumber numberWithInt:segmentsTotal.intValue];
        HSLogBrute(@""); // This is the last log I am getting.
        [transferStatus save];
        HSLogBrute(@"");
    }
    HSLogBrute(@"");// Before putting in the [NSNumber numberWithInt:] calls this was the last line.

1条回答
戒情不戒烟
2楼-- · 2019-04-16 10:22

Turns out we were creating an NSMutableDictionary and using numbers within it. Creating and Destroying NSNumbers as fast as we were doing seems to have confused arc at some point. And the objects were being retained and released out of order.

My solution has been to create a custom object that has the numbers that I need within it. And increment and decrement those primitive number types rather than create and destroy so many NSNumber values.

查看更多
登录 后发表回答