Crashes in CCSprite.cpp Line 643

I get (sometimes) crashes in CCSprite in Cocos2d-x 2.0.4 at Line 643

Any ideas?

Crash report:

0 libGPUSupportMercury.dylib 0x31173e22 gpus_ReturnNotPermittedKillClient + 10 + 9
1 IMGSGX543GLDriver 0x30a596e3 + 246
2 IMGSGX543GLDriver 0x30a59245 + 316
3 GLEngine 0x3251d05d gleBeginPrimitiveTCLFunc + 61 + 60
4 GLEngine 0x324ace35 gleDrawArraysOrElements_ExecCore + 505 + 504
5 GLEngine 0x324a924d glDrawArrays_IMM_ES2Exec + 201 + 200
6 App 0x000ad0cb draw (CCSprite.cpp:643)
7 App 0x0008f8f5 visit (CCNode.cpp:833)
8 App 0x00088d2b ccTouchMoved (DrawScene.cpp:696)
9 App 0x000895c9 0x72000 + 95689
10 App 0x000b449f touches (CCTouchDispatcher.cpp:374)
11 App 0x000b469f 0x72000 + 272031
12 App 0x000a3843 handleTouchesMove (CCEGLViewProtocol.cpp:253)
13 App 0x000a806b ~~
14 UIKit 0x33bb1545~~[UIWindow sendTouchesForEvent:] + 353 + 352
15 UIKit 0x33b9e801 - + 381 + 380
16 UIKit 0x33b9e11b
UIApplicationHandleEvent + 6155 + 6154
17 GraphicsServices 0x31f695a3 _PurpleEventCallback + 591 + 590
18 GraphicsServices 0x31f691d3 PurpleEventCallback + 35 + 34

I have never experience this, but this was a crash report from Apple on an iOS 6.1.3 device, app uses Cocos2D-x v. 2.1.4

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3ba9d350 __pthread_kill + 8
1   libsystem_c.dylib               0x3ba1411e pthread_kill + 54
2   libsystem_c.dylib               0x3ba509f2 __abort + 90
3   libsystem_c.dylib               0x3ba5103e __stack_chk_fail + 194
4   Friends                         0x000839fc -[EAGLView touchesMoved:withEvent:] (EAGLView.mm:434)
5   UIKit                           0x3550f540 -[UIWindow _sendTouchesForEvent:] + 348
6   UIKit                           0x354fc7fc -[UIApplication sendEvent:] + 376
7   UIKit                           0x354fc116 _UIApplicationHandleEvent + 6150
8   GraphicsServices                0x372075a0 _PurpleEventCallback + 588
9   GraphicsServices                0x372071ce PurpleEventCallback + 30
10  CoreFoundation                  0x336c9170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
11  CoreFoundation                  0x336c9112 __CFRunLoopDoSource1 + 134
12  CoreFoundation                  0x336c7f94 __CFRunLoopRun + 1380
13  CoreFoundation                  0x3363aeb8 CFRunLoopRunSpecific + 352
14  CoreFoundation                  0x3363ad44 CFRunLoopRunInMode + 100
15  GraphicsServices                0x372062e6 GSEventRunModal + 70
16  UIKit                           0x355502fc UIApplicationMain + 1116
17  Friends                         0x0004aae6 main (main.m:14)
18  Friends                         0x0004a47c start + 36

Again, I am getting crash reports from iTunes Connect with a recent app built on Cocos2d-x 2.2 running on iOS 7.

Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3b8331fc __pthread_kill + 8
1   libsystem_pthread.dylib         0x3b89ca2e pthread_kill + 54
2   libsystem_c.dylib               0x3b7e4052 __abort + 74
3   libsystem_c.dylib               0x3b7e4684 __stack_chk_fail + 180
4   SesameStreet                    0x0012d954 -[EAGLView touchesMoved:withEvent:] (EAGLView.mm:433)
5   UIKit                           0x333af54e -[UIWindow _sendTouchesForEvent:] + 350
6   UIKit                           0x333aa688 -[UIWindow sendEvent:] + 828
7   UIKit                           0x3337fa20 -[UIApplication sendEvent:] + 192
8   UIKit                           0x3337e21c _UIApplicationHandleEventQueue + 7092
9   CoreFoundation                  0x30bd5188 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
10  CoreFoundation                  0x30bd4656 __CFRunLoopDoSources0 + 202
11  CoreFoundation                  0x30bd2e4a __CFRunLoopRun + 618
12  CoreFoundation                  0x30b3dce2 CFRunLoopRunSpecific + 518
13  CoreFoundation                  0x30b3dac6 CFRunLoopRunInMode + 102
14  GraphicsServices                0x3580b27e GSEventRunModal + 134
15  UIKit                           0x333dfa3c UIApplicationMain + 1132
16  SesameStreet                    0x000f3ff2 main (main.m:14)
17  SesameStreet                    0x000f39c4 ___lldb_unnamed_function1$$SesameStreet + 36

Again, I have not personally been able to reproduce this, so I do not know what is causing it.

A second crash report is different but actually has the same call before abort:

Thread 4 Crashed:
0   libsystem_kernel.dylib          0x3abb21fc __pthread_kill + 8
1   libsystem_pthread.dylib         0x3ac1ba2e pthread_kill + 54
2   libsystem_c.dylib               0x3ab63052 __abort + 74
3   libsystem_c.dylib               0x3ab63684 __stack_chk_fail + 180
4   SesameStreet                    0x00221250 ___lldb_unnamed_function6910$$SesameStreet + 156

What is “__stack_chk_fail” anyway?

Justin Hawkwood wrote:

What is “__stack_chk_fail” anyway?

stack_chk_fail is a function that checks for corruption on the stack and aborts if it finds corruption…. i.e. you are corrupting the stack, you have a memory leak or are overwriting memory

Check you are releasing all you create, check you aren’t using something you previously released, check you aren’t writing past the end of some data block (string,class,memory allocated block,etc).