C ++ Possible Threading Problem - May be Ogre Error

I have a very strange problem in my code. I use Ogre and I try to manually create the material, but I don't think the problem is with Ogre. Links: Header file , Source file , Trace stack . Please excuse random names, comments and std :: cout <. I am desperate and enjoy coding: D

Here is a summary of my code if you do not want to read it:

  • Create root
  • Download plugins
  • Rendering system setup
  • Resource loading
  • Input system setup
  • Create a scene manager.
  • Create a scene
    a. Lighting setup
    b. Manually create material
    with. Adding an object to a scene with manually created material
  • Add frame update callback
  • Start rendering

Now, if I omit steps 7b and 7c, the code works fine and, as expected, and the program prints to the log as expected. But if I turn on steps 7b and 7c, nothing happens and no recording is recorded. The code never finishes the first step. I believe this is a dead end looking at the stack trace, but I donโ€™t know how to solve it - I donโ€™t understand how adding the code later will affect the code earlier, because it will work after the source code, so I suspected a thread problem. Any suggestions are welcome! Thanks in advance, ell.

Edit: Deleted most of the code, leaving only steps 1, 7a, 7b and 7c. I leave the stack trace because it doesnโ€™t take so long!

Here is the violation code:

Step 1 (line 13)

mRoot = new Ogre::Root("", "", "ogre.log"); 

Steps 7a, b, c (lines 146-169)

 mSceneManager->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); std::cout << "Before material creation" << std::endl; //Make cube material Ogre::MaterialPtr cube_material_ptr = Ogre::MaterialManager::getSingleton().create( "trolcherry", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME ); std::cout << "After material creation" << std::endl; // Get a material pass Ogre::Pass *pass = cube_material_ptr->getTechnique(0)->getPass(0); pass->setDiffuse(Ogre::ColourValue(1.0, 0.2, 0.2)); //Make cube Ogre::Entity& cube_entity = *(mSceneManager->createEntity("Head", "Prefab_Cube")); cube_entity.setMaterialName("trolcherry"); Ogre::SceneNode& cube_node = *(mSceneManager->getRootSceneNode()->createChildSceneNode()); cube_node.attachObject(&cube_entity); cube_node.scale(0.3, 0.3, 0.3); 

Stack trace

 #0 ( 0x0012e416 in __kernel_vsyscall() (??:??) #1 0x9b20b9 __lll_lock_wait() (../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/lowlevellock.S:142) #2 0x9af566 pthread_cond_wait@ @GLIBC_2.3.2() (../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:299) #3 0x9223fd __pthread_cond_wait(cond=0xb7bd727c, mutex=0xb7bd7264) (forward.c:139) #4 0x804c65b boost::recursive_mutex::lock(this=0xb7bd7264) (lib/boost_1_47_0/boost/thread/pthread/recursive_mutex.hpp:133) #5 0x804d4af boost::unique_lock<boost::recursive_mutex>::lock(this=0xbffff3c4) (lib/boost_1_47_0/boost/thread/locks.hpp:412) #6 0x47dd96 unique_lock(this=0xb7bd7260, name=..., inGlobalPool=true) (/usr/include/boost/thread/locks.hpp:227) #7 ( Ogre::ResourceGroupManager::createResourceGroup(this=0xb7bd7260, name=..., inGlobalPool=true) (/home/elliot/Programming/C and C++/Project MuffinSnatcher/lib/ogre_src_v1-7-3/OgreMain/src/OgreResourceGroupManager.cpp:84) #8 0x47eaa6 Ogre::ResourceGroupManager::ResourceGroupManager(this=0xb7bd7260) (/home/elliot/Programming/C and C++/Project MuffinSnatcher/lib/ogre_src_v1-7-3/OgreMain/src/OgreResourceGroupManager.cpp:61) #9 0x497bc2 Ogre::Root::Root(this=0xb7ed7260, pluginFileName=..., configFileName=..., logFileName=...) (/home/elliot/Programming/C and C++/Project MuffinSnatcher/lib/ogre_src_v1-7-3/OgreMain/src/OgreRoot.cpp:154) #10 0x804adfe ProjectMuffinSnatcher::Client::Run(this=0xbffff6ec) (/home/elliot/Programming/C and C++/Project MuffinSnatcher/src/Client.cpp:13) #11 0x804e0da main() (/home/elliot/Programming/C and C++/Project MuffinSnatcher/src/main.cpp:6) 

Ldd output

 linux-gate.so.1 => (0x009a3000) libboost_system.so.1.42.0 => /usr/lib/libboost_system.so.1.42.0 (0x00c14000) libOgreMain.so.1.7.3 => /usr/local/lib/libOgreMain.so.1.7.3 (0x00110000) libOIS-1.3.0.so => /usr/local/lib/libOIS-1.3.0.so (0x006d3000) libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x00ce8000) libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x006f4000) libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x00f66000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x0071a000) libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x0087b000) librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x00e7b000) libfreetype.so.6 => /usr/lib/i386-linux-gnu/libfreetype.so.6 (0x008da000) libSM.so.6 => /usr/lib/i386-linux-gnu/libSM.so.6 (0x00e2d000) libICE.so.6 => /usr/lib/i386-linux-gnu/libICE.so.6 (0x00894000) libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0x009a4000) libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0x008ac000) libXt.so.6 => /usr/lib/i386-linux-gnu/libXt.so.6 (0x00abf000) libXaw.so.7 => /usr/lib/libXaw.so.7 (0x00b11000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x008bb000) libboost_thread.so.1.42.0 => /usr/lib/libboost_thread.so.1.42.0 (0x008bf000) libboost_date_time.so.1.42.0 => /usr/lib/libboost_date_time.so.1.42.0 (0x00960000) libfreeimage.so.3 => /usr/lib/libfreeimage.so.3 (0x00f82000) libzzip-0.so.13 => /usr/lib/libzzip-0.so.13 (0x00973000) libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0x0097a000) /lib/ld-linux.so.2 (0x00c2e000) libuuid.so.1 => /lib/i386-linux-gnu/libuuid.so.1 (0x008d4000) libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0x00b6e000) libXmu.so.6 => /usr/lib/libXmu.so.6 (0x00b87000) libXpm.so.4 => /usr/lib/libXpm.so.4 (0x0098f000) libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0x00b9d000) libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0x00ba1000) 
+4
source share
2 answers

I finally fixed my problem. I uninstalled all the boost and ogre related libraries and recompiled boost and then ogre and reinstall them. Now everything is working fine (apparently!). Thanks for all the help, but I think a new reinstall is all I need. Few, I'm glad more!

+1
source

I would make it a comment, but I miss the required representative. :(

A few things to try:

Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME is a static OGRE_AUTO_MUTEX String - instead of passing it directly to the create material manager, first try copying it to a String instance with a local scope. See If this happens, when an error occurs, or if it really fixes it.

Alternatively, I noticed that in the Ogre::Root constructor you explicitly override the default plug-in names and configuration files with "(and do not provide a useful replacement for the log file - change from" Ogre.log "to" ogre. Log " ). Could you try to remove the constructor arguments?

+3
source

All Articles