Search code examples
c++iphonexcodecocos2d-iphonecocos2d-x

Cocos2d-x v4.0 crashing in iPhone Simulator with Xcode 12, Xcode 12.1, Xcode 12.2


Cocos2d-x v4.0 crashing in all iPhone Simulator. In device no crash

glslopt_shader* glslShader = glslopt_optimize(ctx, shaderType, source.c_str(), 0);

For above line everytime crashing. Not using any shader. Above line called by Sprite creation.

auto background = Sprite::create(TEX_MM_BG);

How to fix this crash for simulator ?

enter image description here


Solution

  • With that little info we can't help much. But if I try to interpret the posted image corretly you receive a "EXC_BAD_ACCESS" Exception.

    This means more or less that you access a freed memory region or in general you try dereference a pointer pointing to an invalid memory address.

    The only argument which could cause such an error is source.c_str(). So you should check the code path of source.

    In release builds you don't see always "access-after-free" because memory is not immediately released to the OS (which triggers such errors) it is just marked as "free" to allow faster allocations.