cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

Adding a node's parent as its child causes 37,400-deep recursion and EXC_BAD_ACCESS

Open cartr opened this issue 11 years ago • 1 comments

This code:

CCNode *sprite1 = [CCNode node];
CCNode *sprite2 = [CCNode node];
[sprite2 addChild:sprite1];
[sprite1 addChild:sprite2];

produces an EXC_BAD_ACCESS error with a massive, 37,400-deep stack trace. It looks like the RecursivelyIncrementPausedAncestors recurses infinitely.

While it makes no sense to add a node's parent as its child, it should create some kind of meaningful error instead of crashing with EXC_BAD_ACCESS.

cartr avatar May 21 '14 20:05 cartr

Bwa. I suppose we can have a debug mode assertion that checks if a node to be added is an ancestor of self.

slembcke avatar May 21 '14 21:05 slembcke