[SOLVED] runAction crashing randomly...

[SOLVED] runAction crashing randomly...
0.0 0


Hey guys,

I’m having this strange, and random, crash with runAction, but first let me explain when it’s executed:
My scenes all have an onLoad function that’s executed before the scene becomes active, even before it’s own onEnter, where I load all assets that scene is going to use. I have a GameSceneManager which is responsible for this, as well as effectively changing the scenes:

bool GameSceneManager::setSceneWithTransition(std::string sceneName, CCTransitionScene* transition, float duration) {
    GameScene* nextScene;
    if((nextScene = (GameScene*)getScene(sceneName)) == NULL || transition == NULL)
        return false;


    if(transition && transition->initWithDuration(duration, nextScene))
        currentGameScene = nextScene;
        return true;
    return false;

It works really nice, no problems here. If someone wants it, I can share the GameScene class, which inherits CCScene, from which all my scenes inherits, and the manager.

My first scene just shows a logo while the next one loads:

void StartingScene::runThisScene() {
    CCLayer* layer = new LogoLayer();
        CCLog("Running Scene");

    MainMenuScene* m = (MainMenuScene*)LikeASir::GameSceneManager::getScene("MainMenuScene");

As you can see, here I’m explicitly calling the next scene’s onLoad, as one of its sprites has the crashing runAction, in an attempt to prevent this crash, but with no success. Here are the sprite’s loading and onEnter execution codes:

logo = CCSprite::create(s_LogoPath);
    logo->setPosition(ccp(Constants::screenCenter.x, Constants::screenCenter.y + logo->getContentSize().height / 2 * Constants::maxScale));

CCScaleTo* st = CCScaleTo::create(1.5f, Constants::maxScale);
    CCDelayTime* dt = CCDelayTime::create(2.0f);
    // Show and animate TOUCH!
    CCCallFunc* cf = CCCallFunc::create(this, callfunc_selector(TouchToStartLayer::showTouch));
    CCSequence* s = CCSequence::create(st, dt, cf, NULL);
    CCFadeIn* fi = CCFadeIn::create(1.5f);



(I don’t rely on cocos2d functions’ setDesignResolution as when I tried to use them i failed kkk)

I didn’t find anything wrong here, and it runs, but sometimes I get this crash:

07-30 15:12:57.550: I/DEBUG(10220): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 000000c8
07-30 15:12:57.550: I/DEBUG(10220):  r0 00000000  r1 0018c218  r2 0018c258  r3 000000c8
07-30 15:12:57.550: I/DEBUG(10220):  r4 001876c4  r5 00000000  r6 0018c218  r7 0018c218
07-30 15:12:57.550: I/DEBUG(10220):  r8 44b8cb68  r9 44a8cf50  10 44a8cf3c  fp aca9f368
07-30 15:12:57.550: I/DEBUG(10220):  ip 7f800000  sp 44b8cad8  lr 80928273  pc 8097deba  cpsr 000c0030
07-30 15:12:57.550: I/DEBUG(10220):  d0  07603605c760c030  d1  cf821870af000000
07-30 15:12:57.550: I/DEBUG(10220):  d2  900000178700c100  d3  af00000007040385
07-30 15:12:57.550: I/DEBUG(10220):  d4  cf08c070f7800b70  d5  f7800b70c70ac030
07-30 15:12:57.550: I/DEBUG(10220):  d6  c760c030cf0cc070  d7  cf0ec070f7811970
07-30 15:12:57.550: I/DEBUG(10220):  d8  0000000000000000  d9  0000000000000000
07-30 15:12:57.550: I/DEBUG(10220):  d10 0000000000000000  d11 0000000000000000
07-30 15:12:57.550: I/DEBUG(10220):  d12 0000000000000000  d13 0000000000000000
07-30 15:12:57.550: I/DEBUG(10220):  d14 0000000000000000  d15 0000000000000000
07-30 15:12:57.550: I/DEBUG(10220):  d16 0000000100000001  d17 3fdfffffffffe665
07-30 15:12:57.550: I/DEBUG(10220):  d18 3fe0000000000000  d19 3fe0000000000cce
07-30 15:12:57.550: I/DEBUG(10220):  d20 0000000000000000  d21 000001c900000444
07-30 15:12:57.550: I/DEBUG(10220):  d22 00006b2300000d46  d23 000064100000f724
07-30 15:12:57.550: I/DEBUG(10220):  d24 0000061d0000cd8d  d25 0000064100000db3
07-30 15:12:57.550: I/DEBUG(10220):  d26 0000061d0000cd8d  d27 0000064100000db3
07-30 15:12:57.550: I/DEBUG(10220):  d28 0000061d0000cd8d  d29 0000064100000db3
07-30 15:12:57.550: I/DEBUG(10220):  d30 0000000000000000  d31 0000000000000000
07-30 15:12:57.550: I/DEBUG(10220):  scr 20000010
07-30 15:12:58.929: I/DEBUG(10220):          #00  pc 0017deba  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d6CCNode9runActionEPNS_8CCActionE)
07-30 15:12:58.933: I/DEBUG(10220):          #01  pc 0012826e  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN17TouchToStartLayer8showLogoEv)
07-30 15:12:58.933: I/DEBUG(10220):          #02  pc 00128396  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN13MainMenuScene8showLogoEv)
07-30 15:12:58.933: I/DEBUG(10220):          #03  pc 00128438  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN13MainMenuScene26onEnterTransitionDidFinishEv)
07-30 15:12:58.933: I/DEBUG(10220):          #04  pc 00191b74  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d17CCTransitionScene6onExitEv)
07-30 15:12:58.933: I/DEBUG(10220):          #05  pc 00191b98  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d16CCTransitionFade6onExitEv)
07-30 15:12:58.933: I/DEBUG(10220):          #06  pc 00183c50  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d10CCDirector12setNextSceneEv)
07-30 15:12:58.933: I/DEBUG(10220):          #07  pc 00183e88  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d10CCDirector9drawSceneEv)
07-30 15:12:58.949: I/DEBUG(10220):          #08  pc 00183f08  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (_ZN7cocos2d21CCDisplayLinkDirector8mainLoopEv)
07-30 15:12:58.949: I/DEBUG(10220):          #09  pc 001a5546  /datadata/com.MisterStudios.PorcupineRacing/lib/libPorcupineRacingCore.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender)
07-30 15:12:58.953: I/DEBUG(10220):          #10  pc 00011eb4  /system/lib/libdvm.so
07-30 15:12:58.953: I/DEBUG(10220):          #11  pc 000437d2  /system/lib/libdvm.so (dvmCallJNIMethod_staticNoRef)
07-30 15:12:58.953: I/DEBUG(10220):          #12  pc 000170b4  /system/lib/libdvm.so
07-30 15:12:58.953: I/DEBUG(10220):          #13  pc 0001c164  /system/lib/libdvm.so (dvmMterpStd)
07-30 15:12:58.953: I/DEBUG(10220):          #14  pc 0001b05c  /system/lib/libdvm.so (dvmInterpret)
07-30 15:12:58.953: I/DEBUG(10220):          #15  pc 00059dbc  /system/lib/libdvm.so (dvmCallMethodV)
07-30 15:12:58.957: I/DEBUG(10220):          #16  pc 00059fd0  /system/lib/libdvm.so (dvmCallMethod)
07-30 15:12:58.957: I/DEBUG(10220):          #17  pc 0004e326  /system/lib/libdvm.so
07-30 15:12:58.957: I/DEBUG(10220):          #18  pc 00011e98  /system/lib/libc.so (__thread_entry)
07-30 15:12:58.957: I/DEBUG(10220):          #19  pc 00011a74  /system/lib/libc.so (pthread_create)

As far as I known, it’s saying that some variable was not correctly initialized or is NULL when runAction is trying to execute, but it’s just sometimes, and when I run on XCode, which compiler doesn’t accept so many things as android’s one, this problem does not occur!

I might go with creating the sprite inside onEnter function, but i find this really strange…
If someone knows what the problem might be, please share the info :stuck_out_tongue:



I’m not sure if this will solve your issue but there are a couple things I’ve noticed that could potentially cause some issues.

CCLayer* layer = new LogoLayer();

Don’t use ‘new’, instead create a static Create method that will call LogoLayer’s init() and will call autorelease() (look at CCLayer’s create). Why do you call release()? This might cause some weird issues, I imagine addChild will call retain() so calling release() might cause it to get collected (though you’re never calling autorelease() so it may not be able to be collected at all).

logo = CCSprite::create(s_LogoPath);
logo->setPosition(ccp(Constants::screenCenter.x, Constants::screenCenter.y + logo->getContentSize().height / 2 * Constants::maxScale));

Why call retain()? Should probably just add it as a child to the scene you preloading.

I think those are good tips at least, but I’m not convinced that they’d solve your issue. If you can get your issue isolated to where you can reproduce it consistently, then you might just need to debug into runAction and try to determine why exactly it is crashing.


I’ve tested in XCode and it simply returns an exception:

libc++abi.dylib: terminate called throwing an exception

I’m trying to find now what could have raised it…

  1. Using new to create objects is fine but you have to call the init function on them before adding them.
  2. The logo has to be added to some parent (CCLayer or CCScene or another CCNode) before you call runAction.


Thanks for your help, I’ve changed some stuff, found some variables that weren’t being initialized and now the problem is gone. It’s always the stupidest errors that causes most trouble kkkkk