[2.3] crash creating HlmsPbs

Problems building or running the engine, queries about how to use features etc.
Post Reply
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

[2.3] crash creating HlmsPbs

Post by libolt »

I have been working to port my game code from 2.1 to 2.3 after initially porting it from 1.11 and getting the very basics going thanks to help on here. Now on 2.3 it crashes when creating the HlmsPbs object. It creates the HlmsUnlit object and registers it just fine.

I started with Tutorial00_Basic and pretty much copied the registerHlms() function, making some minor changes for my setup. Now it dies when creating the HlmsPbs object. I'm sure that there is something basic that I am missing but I can't figure it out. Below is my backtrace from GDB to go with the registerHlms() function and the function in my code that calls it.

GDB Backtrace:

Code: Select all

2021-02-01 23:52:31,502 INFO  [default] renderEngine::registerHlms() Pbs Path = Hlms/Pbs/Any/Main
ubc: malloc.c:4064: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)' failed.

Thread 1 "ubc" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49        return ret;
Missing separate debuginfos, use: zypper install libXt6-debuginfo-1.2.1-26.1.x86_64 libopenjp2-7-debuginfo-2.4.0-46.2.x86_64
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff6ab6864 in __GI_abort () at abort.c:79
#2  0x00007ffff6b17eca in __malloc_assert (assertion=assertion@entry=0x7ffff6c24ed8 "(unsigned long) (size) >= (unsigned long) (nb)", file=file@entry=0x7ffff6c204cb "malloc.c", line=line@entry=4064, 
    function=function@entry=0x7ffff6c25380 <__PRETTY_FUNCTION__.2> "_int_malloc") at malloc.c:298
#3  0x00007ffff6b1b978 in _int_malloc (av=av@entry=0x7ffff6c54a00 <main_arena>, bytes=bytes@entry=17) at malloc.c:4064
#4  0x00007ffff6b1c8c1 in __GI___libc_malloc (bytes=bytes@entry=17) at malloc.c:3086
#5  0x00007ffff6e6e969 in operator new (sz=17) at ../../../../libstdc++-v3/libsupc++/new_op.cc:50
#6  0x00007ffff6f037af in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=0xae7e80, __beg=0xdfb910 "Vct_piece_ps.any", __end=<optimized out>)
    at /usr/src/debug/gcc10-10.2.1+git1030-1.2.x86_64/obj-x86_64-suse-linux/x86_64-suse-linux/libstdc++-v3/include/bits/basic_string.tcc:219
#7  0x00007ffff73e5a92 in Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> >::construct (this=0xae65b0, 
    p=0xae7e80, val="Vct_piece_ps.any") at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/include/OgreMemorySTLAllocator.h:175
#8  0x00007ffff73e56f2 in std::allocator_traits<Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_S_construct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> (__a=..., __p=0xae7e80)
    at /usr/include/c++/10/bits/alloc_traits.h:247
#9  0x00007ffff73e508e in std::allocator_traits<Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::construct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> (__a=..., __p=0xae7e80)
    at /usr/include/c++/10/bits/alloc_traits.h:360
#10 0x00007ffff73e4bfc in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::STLAllocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::push_back (this=0xae65b0, __x="Vct_piece_ps.any") at /usr/include/c++/10/bits/stl_vector.h:1192
#11 0x00007ffff74a3d00 in Ogre::Hlms::enumeratePieceFiles (dataFolder=0xca2350, pieceFiles=0xae6598) at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:512
#12 0x00007ffff74a38fb in Ogre::Hlms::enumeratePieceFiles (this=0xe0ac40) at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:469
#13 0x00007ffff74a2594 in Ogre::Hlms::Hlms (this=0xe0ac40, type=Ogre::HLMS_PBS, typeName="pbs", dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0)
    at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreHlms.cpp:313
#14 0x00007ffff7173234 in Ogre::HlmsBufferManager::HlmsBufferManager (this=0xe0ac40, type=Ogre::HLMS_PBS, typeName="pbs", dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0)
    at /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Common/src/OgreHlmsBufferManager.cpp:58
#15 0x00007ffff71c1990 in Ogre::HlmsPbs::HlmsPbs (this=0xe0ac40, dataFolder=0xe0de60, libraryFolders=0x7fffffffbca0) at /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp:318
#16 0x000000000060e3de in renderEngine::registerHlms (this=0x841430) at /home/libolt/Projects/ubc/src/engine/renderengine.cpp:690
#17 0x000000000061001b in renderEngine::createScene (this=0x841430) at /home/libolt/Projects/ubc/src/engine/renderengine.cpp:972
#18 0x00000000006e4db0 in UBC::run (this=0x840080) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
#19 0x00000000006e6307 in main (argc=1, argv=0x7fffffffd5e8) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
registerHlms():

Code: Select all

void renderEngine::registerHlms(void)
{
    std::string func = "renderEngine::registerHlms()";

    logMsg(func +"Setting up HLMS");


#if __ANDROID__
    std::string dataPath = "data";
#else
    std::string dataPath = UBC_DATADIR;
#endif

    hlmsManager = RERoot->getHlmsManager();

    logMsg(func +"Hlms setup");
    Ogre::ConfigFile cf;
 //   cf.load( AndroidSystems::openFile( mResourcePath + "resources2.cfg" ) );


    Ogre::String rootHlmsFolder = dataPath +"/Media/" +
                                  cf.getSetting("DoNotUseAsResource","Hlms","");

    logMsg(func +" " +rootHlmsFolder);
    if( rootHlmsFolder.empty() )
        rootHlmsFolder = "./";
    else if( *( rootHlmsFolder.end() - 1 ) != '/' )
        rootHlmsFolder += "/";

    Ogre::HlmsUnlit *hlmsUnlit = 0;
    Ogre::HlmsPbs *hlmsPbs = 0;

    //For retrieval of the paths to the different folders needed
    Ogre::String mainFolderPath;
    Ogre::StringVector libraryFoldersPaths;
    Ogre::StringVector::const_iterator libraryFolderPathIt;
    Ogre::StringVector::const_iterator libraryFolderPathEn;

    Ogre::ArchiveManager &archiveManager = Ogre::ArchiveManager::getSingleton();


/*    Ogre::Archive *archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
                    dataPath + "/Media/Hlms/Common/GLSL", "FileSystem", true );
    Ogre::ArchiveVec library;
    library.push_back( archiveLibrary );
    Ogre::Archive *archivePbs = Ogre::ArchiveManager::getSingletonPtr()->load(
                  dataPath + "/Media/Hlms/Pbs/GLSL", "FileSystem", true );
//    Ogre::HlmsPbs *hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &library );

//    Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );
    hlmsManager->registerHlms(hlmsPbs);
//    Ogre::Archive *archiveUnlit = Ogre::ArchiveManager::getSingletonPtr()->load(
//                  dataPath + "/Media/Hlms/Unlit/GLSL", "FileSystem", true );
// 2.1    Ogre::HlmsUnlit *hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &library );
//    Ogre::HlmsUnlit *hlmsUnlit = static_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT));
*/

//    const Ogre::String &archiveType = getMediaReadArchiveType();

    {
           // Create & Register HlmsUnlit
           // Get the path to all the subdirectories used by HlmsUnlit
           Ogre::HlmsUnlit::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
           Ogre::Archive *archiveUnlit =
               archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );
           Ogre::ArchiveVec archiveUnlitLibraryFolders;
           libraryFolderPathIt = libraryFoldersPaths.begin();
           libraryFolderPathEn = libraryFoldersPaths.end();
           while( libraryFolderPathIt != libraryFolderPathEn )
           {
               Ogre::Archive *archiveLibrary =
                   archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
               logMsg(func +" Unlit Path = " +*libraryFolderPathIt);

               archiveUnlitLibraryFolders.push_back( archiveLibrary );
               ++libraryFolderPathIt;
           }

           // Create and register the unlit Hlms
           hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &archiveUnlitLibraryFolders );
           Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsUnlit );
       }

       {
           // Create & Register HlmsPbs
           // Do the same for HlmsPbs:
           Ogre::HlmsPbs::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
           Ogre::Archive *archivePbs = archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );

           // Get the library archive(s)
           Ogre::ArchiveVec archivePbsLibraryFolders;
           libraryFolderPathIt = libraryFoldersPaths.begin();
           libraryFolderPathEn = libraryFoldersPaths.end();
           while( libraryFolderPathIt != libraryFolderPathEn )
           {
               Ogre::Archive *archiveLibrary =
                   archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
               logMsg(func +" Pbs Path = " +*libraryFolderPathIt);
               archivePbsLibraryFolders.push_back( archiveLibrary );
               ++libraryFolderPathIt;
           }

           // Create and register
           hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &archivePbsLibraryFolders );
           Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );
       }
createScene():

Code: Select all

bool renderEngine::createScene()
{
    conversionSharedPtr convert ;
    std::string func = "renderEngine::createScene()";
    
    logMsg(func +" begin");

    instance += 1;
//    exit(0);
#ifdef __ANDROID
    logMsg(func +" Hello");
    config = AConfiguration_new();
    logMsg(func +" Mello");
//    exit(0);
//	AConfiguration_fromAssetManager(config, app->activity->assetManager);
//	mAssetMgr = app->activity->assetManager;
    JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();

    jclass class_sdl_activity   = env->FindClass("com/libolt/ubc/UBCActivity");
    jmethodID method_get_native_surface = env->GetStaticMethodID(class_sdl_activity,
                                                                 "getNativeSurface",
                                                                 "()Landroid/view/Surface;");
    jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity,
                                                      method_get_native_surface);
    ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
    
    if ( !native_window )
    {
        logMsg(func +" No Window, Goodbye!");
        return(0);
    }
    
    jclass class_activity = env->FindClass("com/libolt/ubc/UBCActivity");
    jclass class_resources = env->FindClass("android/content/res/Resources");
    jmethodID method_get_resources = env->GetMethodID(class_activity,
                                                      "getResources",
                                                      "()Landroid/content/res/Resources;");
    jmethodID method_get_assets = env->GetMethodID(class_resources,
                                                   "getAssets",
                                                   "()Landroid/content/res/AssetManager;");
    jobject raw_activity = (jobject)SDL_AndroidGetActivity();
    jobject raw_resources = env->CallObjectMethod(raw_activity,
                                                  method_get_resources);
    jobject raw_asset_manager = env->CallObjectMethod(raw_resources,
                                                      method_get_assets);
//    jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity, method_get_native_surface);

//    ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
//    exit(0);
    uint32_t w = ANativeWindow_getWidth(native_window);
    uint32_t h = ANativeWindow_getHeight(native_window);

    logMsg(func +" Width = " +convert->toString(w));
    logMsg(func +" Height = " +convert->toString(h));
    
    setWindowWidth(w);
    setWindowHeight(h);
    
    mAssetMgr = AAssetManager_fromJava(env, raw_asset_manager);
    logMsg(func +" Yello");
    AConfiguration_fromAssetManager(config, mAssetMgr);
    logMsg(func +" Bello");
//	mAssetMgr = app->activity->assetManager;

    Ogre::ArchiveManager::getSingleton().addArchiveFactory(
                new Ogre::APKFileSystemArchiveFactory(mAssetMgr) );
    Ogre::ArchiveManager::getSingleton().addArchiveFactory(
                new Ogre::APKZipArchiveFactory(mAssetMgr) );
    logMsg(func +" Hello?");
//    exit(0);
#endif

    logMsg(func +" winHandle = " +winHandle);

    std::string windowTitle = "Ultimate Basketball Challenge";

    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        misc.insert( std::make_pair("externalWindowHandle",  winHandle) );
    #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
        misc.insert( std::make_pair("parentWindowHandle",  winHandle) );
    #endif

    misc.insert( std::make_pair("title", windowTitle) );
    misc.insert( std::make_pair("gamma",
                                cfgOpts["sRGB Gamma Conversion"].currentValue) );
    if( cfgOpts.find( "VSync Method" ) != cfgOpts.end() )
        misc.insert( std::make_pair( "vsync_method",
                                     cfgOpts["VSync Method"].currentValue ) );
    misc.insert( std::make_pair("FSAA", cfgOpts["FSAA"].currentValue) );
    misc.insert( std::make_pair("vsync", cfgOpts["VSync"].currentValue) );
    misc.insert( std::make_pair("reverse_depth", "Yes" ) );


    mWindow = sharedPtr<Ogre::Window>(
                RERoot->createRenderWindow(windowTitle, windowWidth,
                                           windowHeight, false, &misc));

    logMsg(func +" renderWindow created!");
    std::size_t handle = 0;
    mWindow->getCustomAttribute("WINDOW", &handle);
    logMsg(func +" mWindow handle = " +convert->toString(handle));
    logMsg(func +" Dead");
#ifdef __ANDROID
    sdlWindow = SDL_CreateWindowFrom(mWindow.get());
#endif
     if (mWindow == nullptr)
     {
         logMsg(func +" createScene mWindow == nullptr!");
     }


    mResourceGroup = "UBCData";
//	Ogre::ResourceGroupManager *rsm
    rsm = sharedPtr<Ogre::ResourceGroupManager>(
                Ogre::ResourceGroupManager::getSingletonPtr());
    rsm->createResourceGroup(mResourceGroup);

//    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

#if __ANDROID__
    Ogre::ConfigFile cf;
    cf.load(openAPKFile("resources.cfg"));
    logMsg(func +" or");
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
//exit(0);
    while (seci.hasMoreElements())
    {
        std::string sec, type, arch;
        sec = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;

        for (i = settings->begin(); i != settings->end(); i++)
        {
            type = i->first;
            arch = i->second;
//			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
            rsm->addResourceLocation(arch, type, mResourceGroup);
        }
    }

//	Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

    Ogre::RTShader::ShaderGenerator::initialize();
     // The Shader generator instance
    Ogre::RTShader::ShaderGenerator* shaderGen =
            Ogre::RTShader::ShaderGenerator::getSingletonPtr();
	//Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
    shaderGen->setTargetLanguage("glsles");
    if (mMatListener == nullptr)
    {
        mMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
        Ogre::MaterialManager::getSingleton().addListener(mMatListener);
    }
//    shaderGen->addSceneManager(mSceneMgr);
#else

	// logMsg("Rendering!");
    misc["externalWindowHandle"] = winHandle; //

//    mWindow = RERoot->createRenderWindow("Ultimate Basketball Challenge", 0, 0, false, &misc);

	//    exit(0);
//    mWindow->set
//    mWindow->setVisible(true);
#endif
    logMsg(func +" Alive?");

#if __ANDROID__
    std::string dataPath = "data";
#else
    std::string dataPath = UBC_DATADIR;
//exit(0);

    // load the basic resource location(s)
    rsm->addResourceLocation(dataPath + "/Media", "FileSystem", mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/compositor", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/fonts", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/gui", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/MyGUI_Media", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/models", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials/textures", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials/programs", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materialss/scripts", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/overlays", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/packs", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/skins", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/skins/qgui", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/Audio", "FileSystem",
                             mResourceGroup);
    rsm->initialiseResourceGroup("UBCData", false);

#endif

    registerHlms();  // registers Hlms shader system
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.3] crash creating HlmsPbs

Post by dark_sylinc »

The error you're getting is typical memory corruption. I suggest running your app through valgrind or asan.

Code: Select all

rsm = sharedPtr<Ogre::ResourceGroupManager>(
                Ogre::ResourceGroupManager::getSingletonPtr());
You seem to be capturing our ResourceGroupManager into new smart ptr. This is wrong and will cause corruption when the smart ptr releases the memory.
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

Re: [2.3] crash creating HlmsPbs

Post by libolt »

dark_sylinc,

Thank you for the response. I have stripped out std::shared_ptr usage for all Ogre code. Unfortunately, the problem persists.However, instead of crashing when creating the hlmsPbs object it crashes registering the hlmsPbs object with the HlmsManger:

Code: Select all

           Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );

I ran Valgrind via the support built in to QT Creator. I get a fewe "Invalid write of size" errors followed by a number.

They all seem to be pointing at the following line which is part of the code i mostly lifted from the tutorial

Code: Select all

           hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &archiveUnlitLibraryFolders );

Code: Select all

Invalid write of size 8
  in renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  1: std::_Vector_base<Ogre::ConstBufferPacked*, Ogre::STLAllocator<Ogre::ConstBufferPacked*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_Vector_impl_data::_Vector_impl_data() in /usr/include/c++/10/bits/stl_vector.h:98
  2: std::_Vector_base<Ogre::ConstBufferPacked*, Ogre::STLAllocator<Ogre::ConstBufferPacked*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_Vector_impl::_Vector_impl() in /usr/include/c++/10/bits/stl_vector.h:133
  3: std::_Vector_base<Ogre::ConstBufferPacked*, Ogre::STLAllocator<Ogre::ConstBufferPacked*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_Vector_base() in /usr/include/c++/10/bits/stl_vector.h:288
  4: std::vector<Ogre::ConstBufferPacked*, Ogre::STLAllocator<Ogre::ConstBufferPacked*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::vector() in /usr/include/c++/10/bits/stl_vector.h:487
  5: Ogre::HlmsUnlit::HlmsUnlit(Ogre::Archive*, std::vector<Ogre::Archive*, Ogre::STLAllocator<Ogre::Archive*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >*) in /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp:89
  6: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  7: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  8: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  9: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
Address 0x276d1af0 is 0 bytes after a block of size 1,536 alloc'd  1: operator new[](unsigned long) in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
  2: Ogre::AlignedMemory::allocate(unsigned long, unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:57
  3: Ogre::AlignedMemory::allocate(unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:68
  4: Ogre::StdAlignedAllocPolicy<0ul>::allocateBytes(unsigned long, char const*, int, char const*) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryStdAlloc.h:122
  5: Ogre::AllocatedObject<Ogre::CategorisedAlignAllocPolicy<(Ogre::MemoryCategory)5, 0ul> >::operator new(unsigned long) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryAllocatedObject.h:75
  6: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  7: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  8: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  9: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348

Code: Select all

Invalid write of size 4
  in renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  1: Ogre::HlmsUnlit::HlmsUnlit(Ogre::Archive*, std::vector<Ogre::Archive*, Ogre::STLAllocator<Ogre::Archive*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >*) in /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp:89
  2: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  3: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  4: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  5: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
Address 0x276d1af8 is 8 bytes after a block of size 1,536 alloc'd  1: operator new[](unsigned long) in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
  2: Ogre::AlignedMemory::allocate(unsigned long, unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:57
  3: Ogre::AlignedMemory::allocate(unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:68
  4: Ogre::StdAlignedAllocPolicy<0ul>::allocateBytes(unsigned long, char const*, int, char const*) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryStdAlloc.h:122
  5: Ogre::AllocatedObject<Ogre::CategorisedAlignAllocPolicy<(Ogre::MemoryCategory)5, 0ul> >::operator new(unsigned long) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryAllocatedObject.h:75
  6: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  7: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  8: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  9: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348

Code: Select all

Invalid write of size 8
  in renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  1: Ogre::HlmsUnlit::HlmsUnlit(Ogre::Archive*, std::vector<Ogre::Archive*, Ogre::STLAllocator<Ogre::Archive*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >*) in /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp:89
  2: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  3: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  4: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  5: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
Address 0x276d1b00 is 16 bytes after a block of size 1,536 alloc'd  1: operator new[](unsigned long) in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
  2: Ogre::AlignedMemory::allocate(unsigned long, unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:57
  3: Ogre::AlignedMemory::allocate(unsigned long) in /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreAlignedAllocator.cpp:68
  4: Ogre::StdAlignedAllocPolicy<0ul>::allocateBytes(unsigned long, char const*, int, char const*) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryStdAlloc.h:122
  5: Ogre::AllocatedObject<Ogre::CategorisedAlignAllocPolicy<(Ogre::MemoryCategory)5, 0ul> >::operator new(unsigned long) in /home/libolt/usr/ogre-2.3-sdk/include/OGRE/OgreMemoryAllocatedObject.h:75
  6: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  7: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  8: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  9: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348

Code: Select all

Invalid write of size 1
  in renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
Address 0x276d1b08 is 24 bytes after a block of size 1,536 in arena "client"  1: Ogre::HlmsUnlit::HlmsUnlit(Ogre::Archive*, std::vector<Ogre::Archive*, Ogre::STLAllocator<Ogre::Archive*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >*) in /home/libolt/builds/ogre-build/ogre-2.3/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp:89
  2: renderEngine::registerHlms() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:666
  3: renderEngine::createScene() in /home/libolt/Projects/ubc/src/engine/renderengine.cpp:970
  4: UBC::run() in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
  5: main in /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348
Here is the console output from running Valgrind:

Code: Select all

  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>UnknownInlinedFun</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>155</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>util_queue_thread_func.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../src/util</dir>
      <file>u_queue.c</file>
      <line>289</line>
    </frame>
    <frame>
      <ip>0x84FA196</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>impl_thrd_routine.lto_priv.0.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>UnknownInlinedFun</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>155</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>util_queue_thread_func.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../src/util</dir>
      <file>u_queue.c</file>
      <line>289</line>
    </frame>
    <frame>
      <ip>0x84FA196</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>impl_thrd_routine.lto_priv.0.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>UnknownInlinedFun</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>155</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>util_queue_thread_func.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../src/util</dir>
      <file>u_queue.c</file>
      <line>289</line>
    </frame>
    <frame>
      <ip>0x84FA196</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>impl_thrd_routine.lto_priv.0.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>UnknownInlinedFun</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>155</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>util_queue_thread_func.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../src/util</dir>
      <file>u_queue.c</file>
      <line>289</line>
    </frame>
    <frame>
      <ip>0x84FA196</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>impl_thrd_routine.lto_priv.0.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>UnknownInlinedFun</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>155</line>
    </frame>
    <frame>
      <ip>0x84FA27A</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>util_queue_thread_func.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../src/util</dir>
      <file>u_queue.c</file>
      <line>289</line>
    </frame>
    <frame>
      <ip>0x84FA196</ip>
      <obj>/usr/lib64/dri/radeonsi_dri.so</obj>
      <fn>impl_thrd_routine.lto_priv.0.lto_priv.0</fn>
      <dir>/usr/src/debug/Mesa-drivers-20.3.4-1201.1.x86_64/x86_64-suse-linux/../include/c11</dir>
      <file>threads_posix.h</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
  <stack>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>futex_wait_cancelable</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl/../sysdeps/nptl</dir>
      <file>futex-internal.h</file>
      <line>183</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>__pthread_cond_wait_common</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>508</line>
    </frame>
    <frame>
      <ip>0x4BE56B2</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>pthread_cond_wait@@GLIBC_2.3.2</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_cond_wait.c</file>
      <line>638</line>
    </frame>
    <frame>
      <ip>0x5302C7B</ip>
      <obj>/home/libolt/usr/ogre-2.3-sdk/lib/libOgreMain_d.so.2.3.0</obj>
      <fn>Ogre::WaitableEvent::wait()</fn>
      <dir>/home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/Threading</dir>
      <file>OgreWaitableEvent.cpp</file>
      <line>84</line>
    </frame>
    <frame>
      <ip>0x51EBED1</ip>
      <obj>/home/libolt/usr/ogre-2.3-sdk/lib/libOgreMain_d.so.2.3.0</obj>
      <fn>Ogre::TextureGpuManager::_updateStreamingWorkerThread(Ogre::ThreadHandle*)</fn>
      <dir>/home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src</dir>
      <file>OgreTextureGpuManager.cpp</file>
      <line>2494</line>
    </frame>
    <frame>
      <ip>0x51EBEA3</ip>
      <obj>/home/libolt/usr/ogre-2.3-sdk/lib/libOgreMain_d.so.2.3.0</obj>
      <fn>Ogre::updateStreamingWorkerThread(Ogre::ThreadHandle*)</fn>
      <dir>/home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src</dir>
      <file>OgreTextureGpuManager.cpp</file>
      <line>2487</line>
    </frame>
    <frame>
      <ip>0x51E12DC</ip>
      <obj>/home/libolt/usr/ogre-2.3-sdk/lib/libOgreMain_d.so.2.3.0</obj>
      <fn>Ogre::updateStreamingWorkerThread_internal(void*)</fn>
      <dir>/home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src</dir>
      <file>OgreTextureGpuManager.cpp</file>
      <line>81</line>
    </frame>
    <frame>
      <ip>0x4BDF3E8</ip>
      <obj>/lib64/libpthread-2.32.so</obj>
      <fn>start_thread</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/nptl</dir>
      <file>pthread_create.c</file>
      <line>463</line>
    </frame>
    <frame>
      <ip>0x5CB69C2</ip>
      <obj>/lib64/libc-2.32.so</obj>
      <fn>clone</fn>
      <dir>/usr/src/debug/glibc-2.32-4.1.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64</dir>
      <file>clone.S</file>
      <line>95</line>
    </frame>
  </stack>
Here is the latest version of my registerHlms function with the std::shared_ptr usage stripped out.

Code: Select all

void renderEngine::registerHlms(void)
{
    std::string func = "renderEngine::registerHlms()";

    logMsg(func +"Setting up HLMS");


#if __ANDROID__
    std::string dataPath = "data";
#else
    std::string dataPath = UBC_DATADIR;
#endif

    hlmsManager = RERoot->getHlmsManager();

    logMsg(func +"Hlms setup");
    Ogre::ConfigFile cf;
 //   cf.load( AndroidSystems::openFile( mResourcePath + "resources2.cfg" ) );


    Ogre::String rootHlmsFolder = dataPath +"/Media/" +
                                  cf.getSetting("DoNotUseAsResource","Hlms","");

    logMsg(func +" " +rootHlmsFolder);
    if( rootHlmsFolder.empty() )
        rootHlmsFolder = "./";
    else if( *( rootHlmsFolder.end() - 1 ) != '/' )
        rootHlmsFolder += "/";

    Ogre::HlmsUnlit *hlmsUnlit = 0;
    Ogre::HlmsPbs *hlmsPbs = 0;

    //For retrieval of the paths to the different folders needed
    Ogre::String mainFolderPath;
    Ogre::StringVector libraryFoldersPaths;
    Ogre::StringVector::const_iterator libraryFolderPathIt;
    Ogre::StringVector::const_iterator libraryFolderPathEn;

    Ogre::ArchiveManager &archiveManager = Ogre::ArchiveManager::getSingleton();

    {
           // Create & Register HlmsUnlit
           // Get the path to all the subdirectories used by HlmsUnlit
           Ogre::HlmsUnlit::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
           Ogre::Archive *archiveUnlit =
               archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );
           Ogre::ArchiveVec archiveUnlitLibraryFolders;
           libraryFolderPathIt = libraryFoldersPaths.begin();
           libraryFolderPathEn = libraryFoldersPaths.end();
           while( libraryFolderPathIt != libraryFolderPathEn )
           {
               Ogre::Archive *archiveLibrary =
                   archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
               logMsg(func +" Unlit Path = " +*libraryFolderPathIt);

               archiveUnlitLibraryFolders.push_back( archiveLibrary );
               ++libraryFolderPathIt;
           }

           // Create and register the unlit Hlms
           hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit( archiveUnlit, &archiveUnlitLibraryFolders );
           Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsUnlit );
       }

       {
           // Create & Register HlmsPbs
           // Do the same for HlmsPbs:
           Ogre::HlmsPbs::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
           Ogre::Archive *archivePbs = archiveManager.load( rootHlmsFolder + mainFolderPath, "FileSystem", true );

           // Get the library archive(s)
           Ogre::ArchiveVec archivePbsLibraryFolders;
           libraryFolderPathIt = libraryFoldersPaths.begin();
           libraryFolderPathEn = libraryFoldersPaths.end();
           while( libraryFolderPathIt != libraryFolderPathEn )
           {
               Ogre::Archive *archiveLibrary =
                   archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
               logMsg(func +" Pbs Path = " +*libraryFolderPathIt);
               archivePbsLibraryFolders.push_back( archiveLibrary );
               ++libraryFolderPathIt;
           }

           // Create and register
           hlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &archivePbsLibraryFolders );
           Ogre::Root::getSingleton().getHlmsManager()->registerHlms( hlmsPbs );
       }
       
     Ogre::RenderSystem *renderSystem = RERoot->getRenderSystem();
    if( renderSystem->getName() == "Direct3D11 Rendering Subsystem" )
    {
        //Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
        //and below to avoid saturating AMD's discard limit (8MB) or
        //saturate the PCIE bus in some low end machines.
        bool supportsNoOverwriteOnTextureBuffers;
        renderSystem->getCustomAttribute( "MapNoOverwriteOnDynamicBufferSRV",
                                          &supportsNoOverwriteOnTextureBuffers );

        if( !supportsNoOverwriteOnTextureBuffers )
        {
            hlmsPbs->setTextureBufferDefaultSize( 512 * 1024 );
            hlmsUnlit->setTextureBufferDefaultSize( 512 * 1024 );
        }
    }
}
Am I doing somethign wrong witht he ArchiveManager or libraryFolderPaths? The only real change I made was to set rootHlmsFolder to the path where my Hlms folder resides. I made sure to update the contents to that of the latest git from last night. The path seems to be working because if I modify it then Ogre complains it can't find the Hlms folder.

I'm admittedly a complete novice with Valgrind so I definitely want to learn how to use it to help with any memory issues.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.3] crash creating HlmsPbs

Post by dark_sylinc »

A simple explanation is that there is a binary mismatch. This is quite common. Any (or more than one) of the following could be true:
  • The libOgreMain being loaded is the wrong one. i.e. you're loading an old 2.1/2.2 version
  • A debug lib is being loaded when a Release lib should be used (or viceversa)
  • Same as point 1, but for libOgreHlmsPbs/libOgreHlmsUnlit/libRenderSystem*
  • There is a severe mismatch in compiler arguments (e.g. macros defined). If building with ninja you can check compiler arguments with "ninja -v"; if building with make, use "make VERBOSE=1"
  • The Ogre headers you're building with are from the wrong version
  • Something from an old build didn't get cleaned up and got mixed. Make a clean rebuild of everything
  • OgreBuildSettings.h is being sourced from the wrong location (i.e. the one you're using is not the one Ogre was built with)
GDB's debugger log (in QtCreator right click on a debugger pane, and tick "Global Debugger Log") will list where the libraries are coming from.
Also the tool ldd may help you identify some of the libraries being linked.
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

Re: [2.3] crash creating HlmsPbs

Post by libolt »

Thanks for the explanation. I use a bash script that does a clean build and install of 2.3 into it's own folder. It is supposed to delete the existing folder before running make install but apparently it's not cleaning everything up. I will make sure that all Ogre libraries and headers are purged before doing a fresh build/install. I will report back as soon as that's done.

Thanks again.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.3] crash creating HlmsPbs

Post by dark_sylinc »

I added a new one:
OgreBuildSettings.h is being sourced from the wrong location (i.e. the one you're using is not the one Ogre was built with)

Btw usually the problem is that there is an old header/library lying around and for some reason that version is the one your app ends up picking up.
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

Re: [2.3] crash creating HlmsPbs

Post by libolt »

Thanks for the tips. I did an extensive cleaning of my system to remove old versions of Ogre. I even switched from use make to using ninja to build both Ogre and my project. I am now crashing in my createScene function during window creation. This is before I call registerHlms()

I use SDL2 to create the initial window and get the window handle from it. This has worked correctly going back to at least Ogre 1.9.

This is the error I get:

Code: Select all

* Separate shader objects: no
 * Using Reverse Z: yes
ubc: /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp:255: virtual void Ogre::GL3PlusTextureGpu::_setToDisplayDummyTexture(): Assertion `isRenderWindowSpecific()' failed.
Aborted (core dumped)
This is the line that fails:

Code: Select all

    mWindow = RERoot->createRenderWindow(windowTitle, windowWidth,windowHeight,
                                         false, &misc);
My GDB Backtrace

Code: Select all

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff7113864 in __GI_abort () at abort.c:79
#2  0x00007ffff7113749 in __assert_fail_base (fmt=0x7ffff72806e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7fffec27116a "isRenderWindowSpecific()", 
    file=0x7fffec270f58 "/home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp", line=255, function=<optimized out>) at assert.c:92
#3  0x00007ffff7123016 in __GI___assert_fail (assertion=0x7fffec27116a "isRenderWindowSpecific()", 
    file=0x7fffec270f58 "/home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp", line=255, 
    function=0x7fffec271128 "virtual void Ogre::GL3PlusTextureGpu::_setToDisplayDummyTexture()") at assert.c:101
#4  0x00007fffec242767 in Ogre::GL3PlusTextureGpu::_setToDisplayDummyTexture (this=0xc111a0) at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp:255
#5  0x00007fffec241818 in Ogre::GL3PlusTextureGpu::GL3PlusTextureGpu (this=0xc111a0, pageOutStrategy=Ogre::GpuPageOutStrategy::Discard, vaoManager=0x84a920, name=..., textureFlags=16931, 
    initialType=Ogre::TextureTypes::Type2D, textureManager=0xbef350) at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp:58
#6  0x00007fffec2443a8 in Ogre::GL3PlusTextureGpuRenderTarget::GL3PlusTextureGpuRenderTarget (this=0xc111a0, pageOutStrategy=Ogre::GpuPageOutStrategy::Discard, vaoManager=0x84a920, name=..., 
    textureFlags=16931, initialType=Ogre::TextureTypes::Type2D, textureManager=0xbef350) at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp:742
#7  0x00007fffec24671c in Ogre::GL3PlusTextureGpuWindow::GL3PlusTextureGpuWindow (this=0xc111a0, pageOutStrategy=Ogre::GpuPageOutStrategy::Discard, vaoManager=0x84a920, name=..., textureFlags=16931, 
    initialType=Ogre::TextureTypes::Type2D, textureManager=0xbef350, context=0xa58e90, window=0xa564e0) at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpuWindow.cpp:56
#8  0x00007fffec24607c in Ogre::GL3PlusTextureGpuManager::createTextureGpuWindow (this=0xbef350, context=0xa58e90, window=0xa564e0)
    at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpuManager.cpp:157
#9  0x00007fffec21bdbf in Ogre::GLXWindow::_initialize (this=0xa564e0, _textureManager=0xbef350) at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp:541
#10 0x00007fffec2314b8 in Ogre::GL3PlusRenderSystem::_createRenderWindow (this=0x806500, name="Ultimate Basketball Challenge", width=1280, height=720, fullScreen=false, miscParams=0x7b1128)
    at /home/libolt/builds/ogre-build/ogre-2.3/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp:864
#11 0x00007ffff7b674e0 in Ogre::Root::createRenderWindow (this=0x98f570, name=..., width=<optimized out>, height=<optimized out>, fullScreen=<optimized out>, miscParams=<optimized out>)
    at /home/libolt/builds/ogre-build/ogre-2.3/OgreMain/src/OgreRoot.cpp:1390
#12 0x00000000005bd7e5 in renderEngine::createScene (this=0x7b1010) at /home/libolt/Projects/ubc/src/engine/renderengine.cpp:843
#13 0x000000000067fddc in UBC::run (this=0x7afc60) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:177
#14 0x00000000006812e7 in main (argc=1, argv=0x7fffffffd878) at /home/libolt/Projects/ubc/src/game/ubc/ubc.cpp:348

Here is my createScene() function.

Code: Select all

bool renderEngine::createScene()
{
    conversionSharedPtr convert ;
    std::string func = "renderEngine::createScene()";
    
    logMsg(func +" begin");

    instance += 1;
//    exit(0);
#ifdef __ANDROID
    logMsg(func +" Hello");
    config = AConfiguration_new();
    logMsg(func +" Mello");
//    exit(0);
//	AConfiguration_fromAssetManager(config, app->activity->assetManager);
//	mAssetMgr = app->activity->assetManager;
    JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();

    jclass class_sdl_activity   = env->FindClass("com/libolt/ubc/UBCActivity");
    jmethodID method_get_native_surface = env->GetStaticMethodID(class_sdl_activity,
                                                                 "getNativeSurface",
                                                                 "()Landroid/view/Surface;");
    jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity,
                                                      method_get_native_surface);
    ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
    
    if ( !native_window )
    {
        logMsg(func +" No Window, Goodbye!");
        return(0);
    }
    
    jclass class_activity = env->FindClass("com/libolt/ubc/UBCActivity");
    jclass class_resources = env->FindClass("android/content/res/Resources");
    jmethodID method_get_resources = env->GetMethodID(class_activity,
                                                      "getResources",
                                                      "()Landroid/content/res/Resources;");
    jmethodID method_get_assets = env->GetMethodID(class_resources,
                                                   "getAssets",
                                                   "()Landroid/content/res/AssetManager;");
    jobject raw_activity = (jobject)SDL_AndroidGetActivity();
    jobject raw_resources = env->CallObjectMethod(raw_activity,
                                                  method_get_resources);
    jobject raw_asset_manager = env->CallObjectMethod(raw_resources,
                                                      method_get_assets);
//    jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity, method_get_native_surface);

//    ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
//    exit(0);
    uint32_t w = ANativeWindow_getWidth(native_window);
    uint32_t h = ANativeWindow_getHeight(native_window);

    logMsg(func +" Width = " +convert->toString(w));
    logMsg(func +" Height = " +convert->toString(h));
    
    setWindowWidth(w);
    setWindowHeight(h);
    
    mAssetMgr = AAssetManager_fromJava(env, raw_asset_manager);
    logMsg(func +" Yello");
    AConfiguration_fromAssetManager(config, mAssetMgr);
    logMsg(func +" Bello");
//	mAssetMgr = app->activity->assetManager;

    Ogre::ArchiveManager::getSingleton().addArchiveFactory(
                new Ogre::APKFileSystemArchiveFactory(mAssetMgr) );
    Ogre::ArchiveManager::getSingleton().addArchiveFactory(
                new Ogre::APKZipArchiveFactory(mAssetMgr) );
    logMsg(func +" Hello?");
//    exit(0);
#endif

    logMsg(func +" winHandle = " +winHandle);

    std::string windowTitle = "Ultimate Basketball Challenge";

    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        misc.insert( std::make_pair("externalWindowHandle",  winHandle) );
    #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
        misc.insert( std::make_pair("parentWindowHandle",  winHandle) );
    #endif

    misc.insert( std::make_pair("title", windowTitle) );
    misc.insert( std::make_pair("gamma",
                                cfgOpts["sRGB Gamma Conversion"].currentValue) );
    if( cfgOpts.find( "VSync Method" ) != cfgOpts.end() )
        misc.insert( std::make_pair( "vsync_method",
                                     cfgOpts["VSync Method"].currentValue ) );
    misc.insert( std::make_pair("FSAA", cfgOpts["FSAA"].currentValue) );
    misc.insert( std::make_pair("vsync", cfgOpts["VSync"].currentValue) );
    misc.insert( std::make_pair("reverse_depth", "Yes" ) );


    logMsg(func + " windowTitle = " +windowTitle);
    logMsg(func +" windowWidth = " +convert->toString(windowWidth));
    logMsg(func +" windowHeight = " +convert->toString(windowHeight));

    mWindow = RERoot->createRenderWindow(windowTitle, windowWidth,windowHeight,
                                         false, &misc);

    logMsg(func +" renderWindow created!");
//    std::size_t handle = 0;
//    mWindow->getCustomAttribute("WINDOW", &handle);
//    logMsg(func +" mWindow handle = " +convert->toString(handle));
    logMsg(func +" Dead");
#ifdef __ANDROID
    sdlWindow = SDL_CreateWindowFrom(mWindow.get());
#endif
     if (mWindow == nullptr)
     {
         logMsg(func +" createScene mWindow == nullptr!");
     }


    mResourceGroup = "UBCData";
//	Ogre::ResourceGroupManager *rsm
    rsm = Ogre::ResourceGroupManager::getSingletonPtr();
    rsm->createResourceGroup(mResourceGroup);

//    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

#if __ANDROID__
    Ogre::ConfigFile cf;
    cf.load(openAPKFile("resources.cfg"));
    logMsg(func +" or");
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
//exit(0);
    while (seci.hasMoreElements())
    {
        std::string sec, type, arch;
        sec = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;

        for (i = settings->begin(); i != settings->end(); i++)
        {
            type = i->first;
            arch = i->second;
//			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
            rsm->addResourceLocation(arch, type, mResourceGroup);
        }
    }

//	Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

    Ogre::RTShader::ShaderGenerator::initialize();
     // The Shader generator instance
    Ogre::RTShader::ShaderGenerator* shaderGen =
            Ogre::RTShader::ShaderGenerator::getSingletonPtr();
	//Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
    shaderGen->setTargetLanguage("glsles");
    if (mMatListener == nullptr)
    {
        mMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
        Ogre::MaterialManager::getSingleton().addListener(mMatListener);
    }
//    shaderGen->addSceneManager(mSceneMgr);
#else

	// logMsg("Rendering!");
    misc["externalWindowHandle"] = winHandle; //

//    mWindow = RERoot->createRenderWindow("Ultimate Basketball Challenge", 0, 0, false, &misc);

	//    exit(0);
//    mWindow->set
//    mWindow->setVisible(true);
#endif
    logMsg(func +" Alive?");

#if __ANDROID__
    std::string dataPath = "data";
#else
    std::string dataPath = UBC_DATADIR;
//exit(0);

    // load the basic resource location(s)
    rsm->addResourceLocation(dataPath + "/Media", "FileSystem", mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/compositor", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/fonts", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/gui", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/MyGUI_Media", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/models", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials/textures", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials/programs", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materialss/scripts", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/materials", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/overlays", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/packs", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/skins", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/skins/qgui", "FileSystem",
                             mResourceGroup);
    rsm->addResourceLocation(dataPath + "/Media/Audio", "FileSystem",
                             mResourceGroup);
    rsm->initialiseResourceGroup("UBCData", false);

#endif

    registerHlms();  // registers Hlms shader system
    
#if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 10
    mSceneMgr = sharedPtr<Ogre::SceneManager>(
                RERoot->createSceneManager(Ogre::ST_GENERIC)); // creates the scene manager
#else
    const std::size_t numThreads = std::max<std::size_t>(1,
                                               Ogre::PlatformInformation::getNumLogicalCores() );
    mSceneMgr = RERoot->createSceneManager(Ogre::ST_GENERIC, numThreads,
                                           "UBCSceneManager"); // creates the scene manager
    logMsg(func +"mSceneMgr setup");
#endif

//    mSceneMgr = RERoot->createSceneManager("DefaultSceneManager"); // creates the scene manager

    mCamera = mSceneMgr->createCamera("camera");

    const Ogre::String workspaceName( "MyOwnWorkspace" );
    compositorManager = RERoot->getCompositorManager2();
    Ogre::CompositorChannelVec externalChannels(1);

    if( !compositorManager->hasWorkspaceDefinition( workspaceName ) )
        compositorManager->createBasicWorkspaceDef( workspaceName,
                                                    Ogre::ColourValue( 0.6f,
                                                                       0.0f,
                                                                       0.6f));

    compositorManager->addWorkspace( mSceneMgr, mWindow->getTexture(),
                                     mCamera, workspaceName, true );

    logMsg(func +"Compositor setup");

/*
#ifdef __ANDROID
	mCamera->setNearClipDistance(1.0f);
	mCamera->setFarClipDistance(100000.0f);
	mCamera->setPosition(0, 0, 20.0f);
	mCamera->lookAt(0, 0, 0);
	mCamera->setAutoAspectRatio(true);
#endif
*/


    // Position it at 500 in Z direction
    mCamera->setAutoAspectRatio(true);
    mCamera->setPosition(Ogre::Vector3(0, 0, 455));
    // Look back along -Z
    mCamera->lookAt(Ogre::Vector3(0, 0, -300));

    mCamera->setNearClipDistance(5);
    mCamera->setFarClipDistance(5000);
    cameraNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    mCamera->detachFromParent();
    cameraNode->attachObject(mCamera);
    logMsg(func +"Camera setup");
//    viewPort = sharedPtr<Ogre::Viewport>(mWindow->addViewport(mCamera.get()));
// 2.2    viewPort = sharedPtr<Ogre::Viewport>(mWindow->addViewport());

//    viewPort->setBackgroundColour(Ogre::ColourValue(0, 0, 0));

//    mCamera->setAspectRatio(Ogre::Real(viewPort->getActualWidth()) / Ogre::Real(viewPort->getActualHeight()));

    // most examples get the viewport size to calculate this; for now, we'll just
    // set it to 4:3 the easy way

#ifdef __ANDROID
    viewPort->setMaterialScheme(
                Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
#endif
    viewPort->setOverlaysEnabled(true);	// sets overlays true so that MyGUI can render

    bool overlayEnabled = viewPort->getOverlaysEnabled();
    logMsg(func +" overlayEnabled = " +convert->toString(overlayEnabled));
//.0.236	exit(0);
//    mCamera->setAspectRatio((Ogre::Real)1.333333);

    // Set ambient light
/// OGRE21 Removal
///    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5),
///                               Ogre::ColourValue( 0.6f, 0.45f, 0.3f ) * 0.065f * 0.75f,
///                               -light->getDirection() + Ogre::Vector3::UNIT_Y * 0.2f );


    // Create a light
    light = mSceneMgr->createLight();
    lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    lightNode->attachObject(light);
    lightNode->setPosition(20,80,56);
    light->setPowerScale(1);
    logMsg(func +"light setup");

    if (mWindow == nullptr)
    {
        logMsg(func +" createScene mWindow 2 == nullptr!");
        exit(0);
    }

  logMsg(func +" end");
  
return (true);
}
My initSDL() function:

Code: Select all

bool renderEngine::initSDL() // Initializes SDL Subsystem
{
    conversionSharedPtr convert ;
    std::string func = "renderEngine::initSDL()";
    
    logMsg(func +" begin");

//    exit(0);
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS|SDL_INIT_GAMECONTROLLER) != 0)
    {
//        exit(0);
        logMsg(func +" Unable to initialize SDL: "
               +convert->toString(SDL_GetError()));

        return (true);
    }

//    exit(0);
    
    sdlWindow = SDL_CreateWindow("Ultimate Basketball Challenge",
	                             SDL_WINDOWPOS_UNDEFINED,
	                             SDL_WINDOWPOS_UNDEFINED,
                                 windowWidth,windowHeight,0);
//    exit(0);
    SDL_VERSION( &sysInfo.version );


    if (SDL_GetWindowWMInfo(sdlWindow, &sysInfo) <= 0)
    {
    	assert( false );
    }

    logMsg(func +" end");

	return true;
}
My initOgre function:

Code: Select all

bool renderEngine::initOgre() // Initializes Ogre Subsystem
{
    conversionSharedPtr convert ;
    std::string func = "renderEngine::initOgre()";
    
    logMsg(func +" begin");

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    #ifdef _WIN64
//        winHandle = convert->toString(reinterpret_cast<size_t>(sysInfo.info.win.window));
        winHandle = convert->toString((uintptr_t)sysInfo.info.win.window);
    #else
//        winHandle = convert->toString(reinterpret_cast<unsigned long int>(sysInfo.info.win.window));
        winHandle = convert->toString((uintptr_t)sysInfo.info.win.window);
    #endif
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
//    winHandle = convert->toString(reinterpret_cast<unsigned long>(sysInfo.info.x11.window));
    winHandle = convert->toString((uintptr_t)sysInfo.info.x11.window);
    misc.insert( std::make_pair(
                     "SDL2x11", convert->toString(
                         (uintptr_t)&sysInfo.info.x11 ) ) );
    logMsg(func +"winHandle = " +winHandle);
#elif OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
    JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();

    jclass class_sdl_activity   = env->FindClass("com/libolt/ubc/UBCActivity");
    jmethodID method_get_native_surface = env->GetStaticMethodID(class_sdl_activity, "getNativeSurface", "()Landroid/view/Surface;");
    jobject raw_surface = env->CallStaticObjectMethod(class_sdl_activity, method_get_native_surface);
    ANativeWindow* native_window = ANativeWindow_fromSurface(env, raw_surface);
//    winHandle = convert->toString((unsigned long)sysInfo.info.android.window);
//    winHandle =  convert->toString((unsigned long)SDL_GetWindowID(sdlWindow));
    winHandle =  convert->toString(reinterpret_cast<int>(native_window));
    logMsg(func +" winHandle = " +winHandle);
//    exit(0);
//	logMsg("winHandle2 = " +winHandle2);
	
//	logMsg("grabbed = " +convert->toString(SDL_GetWindowGrab(sdlWindow)));
#else
	// Error, both can't be defined or undefined same time
#endif

//    exit(0);
	//std::cout << "winHandle = " << winHandle << std::endl;
    RERoot = new Ogre::Root("", "", "Ogre.log");
    const std::string pluginDir = OGRE_PLUGIN_DIR;
    logMsg(func +" winHandle for Ogre = " +winHandle);
//    exit(0);
//#ifdef __ANDROID
//#else
//	inputSystem *input = inputSystem::Instance();
//#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    const std::string buildType = BUILD_TYPE;

    if (buildType == "Debug")
    {
//        logMsg(func +"Loading STBI Image Codec Plguin!");
//        RERoot->loadPlugin(pluginDir +"/Codec_STBI_d.dll");

        logMsg(func +" Loading GL Debug RenderSystem!");
//        RERoot->loadPlugin(pluginDir + "/RenderSystem_Direct3D11_d.dll");
        RERoot->loadPlugin(pluginDir + "/RenderSystem_GL3Plus_d.dll");

//        RERoot->loadPlugin(pluginDir + "/Plugin_CgProgramManager_d");
    }
    else
    {
        logMsg(func +"Loading STBI Image Codec Plugin!");
        RERoot->loadPlugin(pluginDir +"/Codec_STBI.dll");
        
        logMsg(func +" Loading GL Release RenderSystem!");
        RERoot->loadPlugin(pluginDir + "/RenderSystem_GL");
//        RERoot->loadPlugin(pluginDir + "/Plugin_CgProgramManager");
    }
#elif OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
	//	    RERoot->loadPlugin();
#ifdef OGRE_STATIC_LIB
    gStaticPluginLoader = new Ogre::StaticPluginLoader();
    gStaticPluginLoader->load();
//    exit(0);
#endif
#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    RERoot->loadPlugin("RenderSystem_GL");
#else

//    RERoot->loadPlugin(pluginDir +"/RenderSystem_GL_d");
    RERoot->loadPlugin(pluginDir + "/RenderSystem_GL3Plus_d");
//    RERoot->loadPlugin(pluginDir + "/Plugin_CgProgramManager");
#endif
//    exit(0);

#ifdef __ANDROID
    RERoot->setRenderSystem(RERoot->getAvailableRenderers().at(0));
#else
    Ogre::RenderSystemList rsList = RERoot->getAvailableRenderers();

    int c = 0;
    bool foundit = false;
    Ogre::RenderSystem *selectedRenderSystem = nullptr;
    while (c < (int)rsList.size())
    {
        selectedRenderSystem = rsList.at(c);
        std::string rname = selectedRenderSystem->getName();
//	if (rname.compare("OpenGL Rendering Subsystem") == 0)
        logMsg(func +" rname == " +rname);
//        exit(0);

        if (rname == "OpenGL Rendering Subsystem"
                || rname == "OpenGL 3+ Rendering Subsystem"
                || rname == "Direct3D11 Rendering Subsystem")
        {
            foundit = true;
            break;
        }
        c++; // <-- oh how clever
        logMsg(convert->toString(c++));
    }
//    exit(0);
	//we found it, we might as well use it!
    if (foundit)
    {
        RERoot->setRenderSystem(selectedRenderSystem);
    }
    else
    {
        logMsg(func +" rendersystem not found!");
	    exit(0);
    }
#endif
    
    
    mWindow = RERoot->initialise(false);

    // sets configuration options for Ogre Window
    cfgOpts =RERoot->getRenderSystem()->getConfigOptions();

    Ogre::ConfigOptionMap::iterator opt = cfgOpts.find( "Video Mode" );

    int width = 1280;
    int height = 720;

    if( opt != cfgOpts.end() && !opt->second.currentValue.empty() )
    {
        //Ignore leading space
        const Ogre::String::size_type start =
                opt->second.currentValue.find_first_of("012356789");
        //Get the width and height
        Ogre::String::size_type widthEnd = opt->second.currentValue.find(' ',
                                                                         start);
        // we know that the height starts 3 characters after the width and goes until the next space
        Ogre::String::size_type heightEnd =
                opt->second.currentValue.find(' ', widthEnd+3);
        // Now we can parse out the values
        width = Ogre::StringConverter::parseInt(
                    opt->second.currentValue.substr( 0, widthEnd ) );
        height =
                Ogre::StringConverter::parseInt( opt->second.currentValue.substr(
                                                     widthEnd+3, heightEnd ) );
    }



    logMsg(func +" OGRE initialized successfully!");
//    exit(0);


    logMsg(func +" end");
    
    return true;
}
Am I possibly doing something that breaks in 2.3?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.3] crash creating HlmsPbs

Post by dark_sylinc »

What platform is this? (OS, version, HW architecture)

I took a look and this is an Ogre bug. It plays with undefined behavior, which is why I didn't detect it before.
Nope, that's not it. It appears GL3PlusRenderSystem::mTextureGpuManager didn't initialize correctly and must be a nullptr (or there's still a binary mismatch and TextureGpu::mTextureGpuManager variable is being looked at the wrong address).

Must be a mistake in the init procedure.
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

Re: [2.3] crash creating HlmsPbs

Post by libolt »

When I get some free time I'm going to go through and redesign my SDL/OGRE init code. As I said before I initially wrote it in the OGRE 1.x days when I transitioned from using OIS for input and there wasn't a whole lot of documentation on how to integrate OGRE with SDL2. So I will try to mimic how things are done with the current tutorials.

Thanks again for helping with this and all the work on 2.x.
Post Reply