Cocos2D 2.1 and Apple LLVM 5.0 problem

Hello World.
Yes, simple applications usually works. The very first computer program of each programmer is well known “hello world”.
Today I would like to share with you, what problem I have recently resolved. The bug occured when I upgraded my iOS development environment to the Xcode with Apple’s LLVM 5.0.

Firstly, I was thinking that was related with Cocos2D (but it wasn’t). My game application was crashing _sometimes_ when it was starting and sometimes when it was running few seconds. The problem pointed me to the OpenGL instructions managment. I thought that the problem was with bad code of Cocos2D framework. All signs at the sky showed me that there might a problem with sprites handling. The framework is multithreaded so, firstly I was suspecting stability of the framework. Let’s get to the point.


Application crashes with various errors like:


The source of those errors are at the LLVM instructions level at assembler code level.
Sources of error could be instructions like:

  • llvm::PointerType::get(llvm::Type const*, unsigned int)
  • llvm::SelectionDAG::getNode();

and similiar to that instructions.
Stack trace llvm jit.
Screenshot show some stack trace. You might look at it in order to compare with your situation.
I have a stackoverflow topic at


I have tried many things, trim down my code and then activating modules bit by bit, debugging step by step. It didn’t helped me.
Then, I decided to clear ALL my memory leaks (even those least significant). After that, ALL my issues disappeared! :)
So, the solution was to clear all memory leaks. Even if you think that some memory leaks may not be important, REMOVE them, because they might show up few weeks/months later. And debugging them.. wil be just painful and time wasteful.

I hope it was somehow helpful for you.