Crash objc_retain_x0

Attaching several crash traces:

The final code:

- (NSObject*)objectAtIndex:(NSUInteger)index {
    if (index < self.count) {
        return [self.embeddedArray objectAtIndex:index];
    } else {
        [PNDErrorReporting reportError:PNDErrorReasonTypeSafeCollectionCrashPrevented message:@"Error msg"];
        return nil;
    }
}

We subclass NSMutableArray to prevent potential crashes. but we encounter a new crash in our sdk for one of the clients. Also we noticed the stack trace skipped one of the frames (stack calls) in the crash report, in which cases the stack trace wont be identical to the actual code (beside inline)?

We subclass NSMutableArray to prevent potential crashes.

Say what?

we encounter a new crash in our sdk for one of the clients.

Is this the same client as in your other thread?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Subclassing Notes

Not common but defiantly possible, described in apple docs.

Yes same client :(

@DTS Engineer

Any progress on that or some explanation about the crash?

Not common but defiantly possible, described in apple docs.

Yeah, sure, but it’s a bad idea in general and a terrible idea if your goal is “to prevent potential crashes”.

Yes same client :(

OK then. IMO there’s something really broken within that app and you need to fix that before you start worrying about this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@DTS Engineer

but could you please explain the crashes?

The immediate cause of these crashes is that you’ve passed a bogus object to objc_retain_x0 (a specialised form of objc_retain used on Apple silicon). You’re doing this from your array subclass, so there are two potential causes:

  • There’s a bug in your array subclass.

  • The process’s state is corrupted such that your legitimate code is crashing.

Regarding the first, IMO you shouldn’t have this array subclass in the first place, so I’m not inclined to go looking for bugs in it.

Regarding the second, we know from your other thread that this process’s state is corrupted because it’s causing other code to crash.

My advice is that your remove your array subclass and then hunt your memory corruption issue (well, your client’s memory corruption issue).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@DTS Engineer

both crashes occurs in 2 different places under 2 different threads.

The current one is related to the processing of the payload we received from the BE and runs in sync queue.

While the previous crash runs and different sync queue and its purpose is to handle app analytics as soon as one is received.

With that to say its hard for me to directly link between the two issues except of some general memory corruption

With that to say its hard for me to directly link between the two issues except of some general memory corruption

Well, yes, that’s exactly the point I’m making. AFAICT the crash on that other thread can only occur due to a memory corruption issue. Given that the crash on this thread only occurs when your SDK is integrated into the same client, my theory is that the same underlying memory corruption is causing both problems.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Crash objc_retain_x0
 
 
Q