2

I am experimenting an EXC_BAD_ACCESS error that I can not solve, so here I am introducing it to you hoping to get some help :)

Normally I use to solve this kind of errors using instruments-zombies, but this time it doesn't seem that easy...

As you can see in the attached image, it looks like I have no interaction with this object; it's only retained/released by UIKit and QuartzCore, so I don't know where to look or what to do to solve it.

Any hint? Thanks!

Image URL: https://i.stack.imgur.com/6R7f0.png enter image description here

Ricard Pérez del Campo
  • 2,387
  • 1
  • 19
  • 22
  • 2
    Not enough information to be able to say what the problem is, other than you've got a deallocated object that is still being referenced. Check that you have strong pointers to objects that you don't want to be deallocated. – Kekoa Dec 20 '12 at 21:42
  • Yes, that's what I have checked the first, but the project is very very big and it's easy to forget something... Using instruments I expected to see which of my methods did release the object, but it's never done by me, that's why I feel so confused! Thank you! – Ricard Pérez del Campo Dec 20 '12 at 22:36
  • Are you using multiple threads? – Lefteris Dec 31 '12 at 14:57
  • Yes, I am. The application uses multiple threads for a lot of things, but I can't know if the error is happening in the main thread or not, right? Well, actually I can suppose it's the main thread because it's something related with uikit, which always runs in the main thread (I guess). – Ricard Pérez del Campo Dec 31 '12 at 15:54
  • At which code or action doing, you are getting this error?? You need to specify that atleast and provide which code leads to this error.. – Dinesh Raja Jan 07 '13 at 14:10

2 Answers2

2

Since you are saying you are using multi threading, I'm pretty sure that this is your problem:

UIKit, although advertised as thread safe since iOS4, is not entirely thread safe. It does internal calls to UIStringDrawing, which is not thread safe and you end up with those crashes. Look here: UIStringDrawing methods don't seem to be thread safe in iOS 6

Try drawing your text in CATextLayer instead

Community
  • 1
  • 1
Lefteris
  • 14,550
  • 2
  • 56
  • 95
  • This may be related with my problem, but it doesn't help me very much right now... I need to find where the problem occurs so then I will use your solution. But first I need to find the part of my code that makes it crash, and I just don't know where to look at. Thank you very much anyway! – Ricard Pérez del Campo Jan 01 '13 at 21:15
  • 1
    If you add an exception breakpoint in Xcode to break in all exceptions and run the app it should stop on the crash point! – Lefteris Jan 01 '13 at 22:11
0

I'm a bit curious why and how you are using a shared CALayer? Working with CALayers isn't that performance expensive in my experience, are you sharing the CALayer between two views or what? In that case my recommendation and answer would be to not share it, and have two CALayers instead. Unless you have a use-case that is good of course, but I can't think of any.

Good luck!

Anders
  • 2,903
  • 7
  • 58
  • 114
  • I absolutely don't know what was going on... I wasn't the responsible of that layer (at least that is what instruments say...). I finally have redone the main view controller (where this happened randomly) and now it's not happening anymore. – Ricard Pérez del Campo Jan 05 '13 at 15:22