Why does running an Action inside update() crashes the application?

Good day,

The scenario is this, I have 3 sprites and I want to execute actions to them using sequence, inside the update().
Another thing if the sprite is still executing the action, it will not acquire new action but if it is done executing the action it will create a new action then execute it.

I used .isDone() for the checking.

Here is the pseudo code:

Legend for readability:
SampleSprite - assuming that this is the sprite.
isStillOnAction - boolean, true if currently executing action, false if not.
RANDOM NUMBER FROM 2-5 - is a random number from 2 to 5.

for(int ctr = 0; ctr < 3; ctr++)
{
	if(!SpriteSample[ctr].isStillOnAction)			// not currently executing action, so we can now assign an action
	{
		SampleSprite[ctr].isStillOnAction = true;	// the isStillOnAction boolean is changed to true
					
		if(SampleSprite[ctr].facingDirection == 1)
		{
			SampleSprite[ctr].moveAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 0, 100 ) );
			SampleSprite[ctr].stoppingAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 10, 0 ) );
		}
		else if(SampleSprite[ctr].facingDirection == 2)
		{
			SampleSprite[ctr].moveAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 0, -100 ) );
			SampleSprite[ctr].stoppingAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 10, 0 ) );
		}
		else if(SampleSprite[ctr].facingDirection == 3)
		{
			SampleSprite[ctr].moveAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( -100, 0 ) );
			SampleSprite[ctr].stoppingAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 0,10 ) );
		}
		else if(SampleSprite[ctr].facingDirection == 4)
		{
			SampleSprite[ctr].moveAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 100, 0 ) );
			SampleSprite[ctr].stoppingAction = cocos2d::MoveBy::create( RANDOM NUMBER FROM 2-5, cocos2d::Vec2( 0, 10 ) );
		}
		
		SampleSprite[ctr].moveStopAction = cocos2d::Sequence::create(SampleSprite[ctr].moveAction, SampleSprite[ctr].stoppingAction, nullptr);
		SampleSprite[ctr].characterSprite->runAction( SampleSprite[ctr].moveStopAction );
	}
	else	// currently executing action
	{
			if(SampleSprite[ctr].moveStopAction->isDone())			// check if done executing action
			{
				SampleSprite[ctr].isStillOnAction = false;			
			}
	}
}

Result:
It runs the sequence action but after that it freezes then it crashes.

What is the possible problem that I overlooked?

Thank you in advance :smile:

where does it crash? what is the crash? are these Sprites out of scope in update()?