[Windows] Errors on Startup

Hi all,

I’m getting a variety of intermittent errors on startup of my app in both Debug and Release build modes. The problem doesn’t happen all the time, and 2/5 times the app starts just fine. I’m using VS2012 and Cocos2d-x 3.2.

The errors (Debug mode):
Access violation 0xC0000005: Access violation reading location 0x000001C0
Occurs at this line in GLProgramState::applyGLProgram(const Mat4& modelView)
CCASSERT(_glprogram, “invalid glprogram”);

Access violation 0xC0000005: Access violation reading location 0xBAAD0115
Occurs at this line in GLProgram::use():
GL::useProgram(_program);

Error (Release mode):
Access violation 0xC0000005: Access violation reading location 0xBAADF00D.
Occurs at this line in int APIENTRY _tWinMain():
return Application::getInstance()->run();

I have no idea at all is causing these errors, and they’re very difficult to debug as they don’t reliably appear!

Any help very much appreciated :smile:

I’m shooting from the hip here but did you recently upgrade the project to v3.2 from some other version?

Hi, thanks for replying. It’s a fresh 3.2 project, no upgrade.

ok, darn. I’ve seen this before when users upgrade and don’t do a ‘clean’ and re-build. Sometimes things get confused and the ‘clean’ starts them off at square 0 again.

I’ve worked out what the problem was. I was using a sprite to draw to a RenderTexture and calling retain() on the sprite beforehand (as I understand you have to now). Then I was re-instantiating and using the sprite later, but without calling retain() on it. Turns out the Cocos2d-x does not like this…