Crash in TextureCache

I just upgraded from 2.0.4 to 3.0 alpha1 for the better multi-project support. I have been getting an off-and-on again crash with the TextureCache as a result of using Sprites. Here’s a snippet of my code where this problem starts:

Sprite* dialogSprite = Sprite::create("dialog_exitconfirm.png");

Here’s the stack trace:

    ntdll.dll!77080574()    Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
    ntdll.dll!7703b0b2()    Unknown
    ntdll.dll!76fe3cfe()    Unknown
    ntdll.dll!76fe3cfe()    Unknown
    ntdll.dll!76fe3cfe()    Unknown
    ntdll.dll!7708106e()    Unknown
    msvcr110d.dll!_heap_alloc_base(unsigned int size) Line 57   C
    msvcr110d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 431 C++
    msvcr110d.dll!_nh_malloc_dbg_impl(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239  C++
    msvcr110d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine) Line 302    C++
    msvcr110d.dll!malloc(unsigned int nSize) Line 56    C++
    msvcr110d.dll!operator new(unsigned int size) Line 59   C++
    TreatWorld.exe!std::_Allocate,std::allocator > const ,cocos2d::Texture2D *>,void *> >(unsigned int _Count, std::_List_node,std::allocator > const ,cocos2d::Texture2D *>,void *> * __formal) Line 28    C++
    TreatWorld.exe!std::allocator,std::allocator > const ,cocos2d::Texture2D *>,void *> >::allocate(unsigned int _Count) Line 591 C++
    TreatWorld.exe!std::_Wrap_alloc,std::allocator > const ,cocos2d::Texture2D *>,void *> > >::allocate(unsigned int _Count) Line 877  C++
    TreatWorld.exe!std::_List_alloc<0,std::_List_base_types,std::allocator > const ,cocos2d::Texture2D *>,std::allocator,std::allocator > const ,cocos2d::Texture2D *> > > >::_Buynode0(std::_List_node,std::allocator > const ,cocos2d::Texture2D *>,void *> * _Next, std::_List_node,std::allocator > const ,cocos2d::Texture2D *>,void *> * _Prev) Line 788  C++
    TreatWorld.exe!std::_List_buy,std::allocator > const ,cocos2d::Texture2D *>,std::allocator,std::allocator > const ,cocos2d::Texture2D *> > >::_Buynode,std::allocator >,cocos2d::Texture2D *> >(std::_List_node,std::allocator > const ,cocos2d::Texture2D *>,void *> * _Next, std::_List_node,std::allocator > const ,cocos2d::Texture2D *>,void *> * _Prev, std::pair,std::allocator >,cocos2d::Texture2D *> && _V0) Line 850   C++
    TreatWorld.exe!std::list,std::allocator > const ,cocos2d::Texture2D *>,std::allocator,std::allocator > const ,cocos2d::Texture2D *> > >::_Insert,std::allocator >,cocos2d::Texture2D *> >(std::_List_unchecked_const_iterator,std::allocator > const ,cocos2d::Texture2D *> > >,std::_Iterator_base0> _Where, std::pair,std::allocator >,cocos2d::Texture2D *> && _V0) Line 1086 C++
    TreatWorld.exe!std::list,std::allocator > const ,cocos2d::Texture2D *>,std::allocator,std::allocator > const ,cocos2d::Texture2D *> > >::emplace_front,std::allocator >,cocos2d::Texture2D *> >(std::pair,std::allocator >,cocos2d::Texture2D *> && _V0) Line 1086    C++
    TreatWorld.exe!std::_Hash,std::allocator >,cocos2d::Texture2D *,std::_Uhash_compare,std::allocator >,std::hash,std::allocator > >,std::equal_to,std::allocator > > >,std::allocator,std::allocator > const ,cocos2d::Texture2D *> >,0> >::insert,std::allocator >,cocos2d::Texture2D *> >(std::pair,std::allocator >,cocos2d::Texture2D *> && _Val) Line 385  C++
>   TreatWorld.exe!cocos2d::TextureCache::addImage(const std::basic_string,std::allocator > & path) Line 314  C++
    TreatWorld.exe!cocos2d::Sprite::initWithFile(const std::basic_string,std::allocator > & filename) Line 222    C++
    TreatWorld.exe!cocos2d::Sprite::create(const std::basic_string,std::allocator > & filename) Line 88   C++
    TreatWorld.exe!stf::ExitConfirmDialog::ExitConfirmDialog(gnelson_coretech::IDialogListener * listener, stf::Decoration * buttonNoData, stf::Decoration * buttonYesData) Line 24 C++

It looks like it starts to freak out around the time it enters the STD library. I’m using VS 2012, but this happens on the Mac version as well. It’s just easier to debug in Windows :slight_smile:

I went through this too on OS X. Are your .png’s in the texture cache at that time when you create()?

No they’re not. I haven’t added them there. Hmmm… worth a try though!
Now I’m having issues with XCode cooperating. Keeps getting stuck on creating the universal binary.

Have you considered using SpriteCache and a sprite sheet? This works well.

Look over the settings for the HelloWorld and that should help with the build settings you need.

Maybe use the create_project script and create a HelloWorld. That will have everything you need. Then re-name it, refactor a small bit and add all of your code and go?

Yeah that’s what I’ve done. I had this working just fine before, but the Mac support was crap. I upgraded Cocos2dx to 2.2 for the multi-project creation support. I just ported everything over. Win32 and iOS are compiling and running fine. Mac has some major issues, which is a damn shame, because it’s for my kids’ mac that I’m doing this.

I do Mac, ios, win32, etc and I dont believe that mac support is crap.

To clarify: I meant for templates and Xcode integration, not the code itself. :slight_smile:

ok, that’s better. I can agree to that. Make sure you are running the latest v3 from GitHUB. Then improve things a lot there. I know at this point you can use the create-project script and specify your own project name and it will do everything correctly.

Also, look at SpriteCache and sprite sheets. I think this will help out a lot.

Aha. I had downloaded it straight from the website.

Seems to be a little more stable with the current way I’ve written things under 2.2 though. I got that running just fine last night.

I’ll look into the SpriteCache!