[2.2] Help understanding initialise resource group crash [SOLVED] Topic is solved

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

[2.2] Help understanding initialise resource group crash [SOLVED]

Post by old_man_auz »

Hi,
I recently decided to see if I could get the Terra terrain component working in my project. Before implementation, the flow of my code was:

Code: Select all

1) Create and initialise Ogre::Root
2) Add my resources into an "Assets" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit HLMS resources
4) Load Texture & HLMS disk caches
5) Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);
6) Create scene manager
7) Create camera
8) Setup compositor
So looking at "Tutorial_Terrain.cpp" from the Ogre source, I made the following changes:

Code: Select all

2) Add my resources into an "Assets" resource group & Add the needed terrain resources into a "Terrain" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit + Terra HLMS resources
As far as I can tell, I'm doing everything in exactly the same order as the tutorial. This resulted in just a straight crash to desktop with no errors in the Ogre log file. The last line in the log file was: "Parsing script Terra.material.json". The outcome was the same with either the DirectX11 or OpenGL3+ rendersystem.

To fix the crash, this I did the following:

Code: Select all

1) Create and initialise Ogre::Root
2) Add my resources into an "Assets" resource group & Add the needed terrain resources into a "Terrain" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit HLMS resources
4) Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Terrain", true);
5) Load Terra HLMS resources
6) Load Texture & HLMS disk caches
7) Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);
8) Create scene manager
9) Create camera
10) Setup compositor
So what makes Ogre crash silently in "Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);"?

Thanks.
Last edited by old_man_auz on Sat Oct 09, 2021 1:43 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4757
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1044
Contact:

Re: [2.2] Help understanding initialise resource group crash

Post by dark_sylinc »

Hi!

Do you have a callstack?

Just to be sure I'd put the terrain resources in "General" rather than "Terrain" group. I don't see step 4 needs to be done separately. You should be able to do it in step 7.

That should be fine as long as you create your Ogre::Terra pointer after step 10. You should be able to create your HlmsTerra pointer at step 3 alongside PBS and Unlit.

Cheers
Matias
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

Re: [2.2] Help understanding initialise resource group crash

Post by old_man_auz »

Call stack is below. Is that saying that it is crashing in rapidjson? If it matters:
- I'm using rapidjson version: 1.1.0
- If I remove "Terra.material.json" then it stops crashing at "initialiseAllResourceGroups"
- I recopied "Terra.material.json" from the sdk to make sure I hadn't accidently edited it
- In "Terra.material.json" what is "unique_name" supposed to be from line: "sampler" : "unique_name"

Code: Select all

 	ucrtbased.dll!00007ffdaec31a65()	Unknown
 	ucrtbased.dll!00007ffdaec31883()	Unknown
 	ucrtbased.dll!00007ffdaec341cf()	Unknown
>	total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember<rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & name) Line 1154	C++
 	total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember(const char * name) Line 1134	C++
 	total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember(const char * name) Line 1137	C++
 	total_destruction_win_d.exe!Ogre::HlmsJsonTerra::loadMaterial(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & json, const Ogre::HlmsJson::NamedBlocks & blocks, Ogre::HlmsDatablock * datablock, const std::string & resourceGroup) Line 229	C++
 	total_destruction_win_d.exe!Ogre::HlmsTerra::_loadJson(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & jsonValue, const Ogre::HlmsJson::NamedBlocks & blocks, Ogre::HlmsDatablock * datablock, const std::string & resourceGroup, Ogre::HlmsJsonListener * listener, const std::string & additionalTextureExtension) Line 699	C++
 	[External Code]	
 	total_destruction_win_d.exe!RenderManager::Initialise(std::string windowtitle) Line 84	C++
 	total_destruction_win_d.exe!Engine::Initialise() Line 136	C++
 	total_destruction_win_d.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 23	C++
 	[External Code]	
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

Re: [2.2] Help understanding initialise resource group crash

Post by old_man_auz »

More info if this is useful:
Image

Does the "HlmsTerra::_loadJson" call initiate from inside the "OgreMain.dll" or "OgreHlmsPbs.dll"?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4757
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1044
Contact:

Re: [2.2] Help understanding initialise resource group crash

Post by dark_sylinc »

Ahh! Something you posted made me suspect of what's going on.

I think you're mixing a Release build of Ogre with your Debug build. You have 2 choices:
  1. Use a Debug build of Ogre with the Debug build of your app
  2. In your compiler set the macro OGRE_DEBUG_MODE to 0, i.e. in Visual Studio go to Alt+F7 C++ -> Preprocessor Directives -> Preprocessor Defintitions and add "OGRE_DEBUG_MODE=0;" (no quotes).
I'd recommend a Debug Ogre build because there are more debug checks performed to detect incorrect usage.

Cheers
Matias

PS btw to reveal [External Code] in the call stack right click and tick "Show External Code".
PS 2 Please make sure the Rapidjson you're using is exactly the same that Ogre was built with. Otherwise you'll get nasty crashes.
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

Re: [2.2] Help understanding initialise resource group crash

Post by old_man_auz »

I didn't think I was mixing my debug with Ogre release? My debug configuration:
- I have the "_DEBUG" prepocessor definition.
- Linking against "ogre-sdk-v2.2.5-vc19-x64\lib\Debug" folder in the sdk
- Additional dependencies are "OgreHlmsPbs_d.lib;OgreHlmsUnlit_d.lib;OgreMain_d.lib"
- Using the "*_d.dll" files

1) Or do I need to compile Ogre from source in debug mode?
2) Just to clarift, your option number 2 > "OGRE_DEBUG_MODE=0;" is if I want my code in debug mode, but Ogre's in release?
3) Yep, it was a rapidjson version error. I recompiled with the Rapidjson code from the "ogre-next-deps" and it is working now.
4) Is it worth putting a link to the "ogre-next-deps" git hub repo at "https://www.ogre3d.org/download/sdk/sdk-ogre-next"? It wasn't obvious to me that it existed. Or a reference to it in the readme at "OGRECave/ogre-next"?

Thanks for the help
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4757
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1044
Contact:

Re: [2.2] Help understanding initialise resource group crash

Post by dark_sylinc »

old_man_auz wrote: Fri Oct 08, 2021 11:41 pm I didn't think I was mixing my debug with Ogre release? My debug configuration:
- I have the "_DEBUG" prepocessor definition.
- Linking against "ogre-sdk-v2.2.5-vc19-x64\lib\Debug" folder in the sdk
- Additional dependencies are "OgreHlmsPbs_d.lib;OgreHlmsUnlit_d.lib;OgreMain_d.lib"
- Using the "*_d.dll" files

1) Or do I need to compile Ogre from source in debug mode?
No need. You did it well. That is enough ;)
2) Just to clarift, your option number 2 > "OGRE_DEBUG_MODE=0;" is if I want my code in debug mode, but Ogre's in release?
That's right. If you want to use Ogre in Release while your code in Debug (hopefully I didn't miss anything; ensuring Release Ogre works in Debug is in my long TODO list, but there's a lot of platforms we support where that may be an issue).
3) Yep, it was a rapidjson version error. I recompiled with the Rapidjson code from the "ogre-next-deps" and it is working now.
Yay! :D
4) Is it worth putting a link to the "ogre-next-deps" git hub repo at "https://www.ogre3d.org/download/sdk/sdk-ogre-next"? It wasn't obvious to me that it existed. Or a reference to it in the readme at "OGRECave/ogre-next"?
It's usually part of the building instructions in the manual, since you're using our prebuilt SDK I guess you couldn't possibly see it.

I didn't realize not knowing the existence of ogre-next-deps could be an issue if you're integrating some of our code due to rapidjson. I'll update the front page in Github at the very least.
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

Re: [2.2] Help understanding initialise resource group crash

Post by old_man_auz »

So, linking against Ogre debug, should I be able to step into the external ogre code contained in dll?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4757
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1044
Contact:

Re: [2.2] Help understanding initialise resource group crash

Post by dark_sylinc »

old_man_auz wrote: Sat Oct 09, 2021 12:16 am So, linking against Ogre debug, should I be able to step into the external ogre code contained in dll?
Yes, you said you are already linking against OgreMain_d & co. so you could be able to step into them.

Just tell Visual Studio to "Show External Code". And you may also need to download our source code from Github and tell Visual Studio where it is located.
old_man_auz
Halfling
Posts: 96
Joined: Tue Jun 15, 2004 5:10 am
Location: Australia

Re: [2.2] Help understanding initialise resource group crash

Post by old_man_auz »

Thanks!
Post Reply