Page 1 of 1

Crash in the ControllerManager::updateAllControllers

Posted: Sat Sep 07, 2024 2:13 am
by altren

So I was having segfault in the ControllerManager::updateAllControllers because nullptr object was used.
Debugging showed me that mControllers vector was modified inside range based loop and then ci object was 0. I tested and found that ControllerManager::createController was called within loop.
Modifying container we are iterating over must cause problems, but what I'm not sure if such modification is expected.
Changes below fixes the issue, but I want to double check that calling ControllerManager::createController from update() is possible. And I'm totally unfamiliar with all this controllers and what they can do.

Code: Select all

    void ControllerManager::updateAllControllers(void)
    {
        // Only update once per frame
        unsigned long thisFrameNumber = Root::getSingleton().getNextFrameNumber();
        if (thisFrameNumber != mLastFrameNumber)
        {
            // master version
            //for (auto *ci : mControllers)
            //{
            //    ci->update();
            //}
            for (size_t i = 0; i < mControllers.size(); ++i)
            {
            	mControllers[i]->update();
            }
            mLastFrameNumber = thisFrameNumber;
        }
    }

Re: Crash in the ControllerManager::updateAllControllers

Posted: Sat Sep 07, 2024 1:48 pm
by sercero

Hello @altren is this an issue with OGRE?

Perhaps it would be better if you opened a pull request with your changes so that @paroj can see what is the problem in context.
:D


Re: Crash in the ControllerManager::updateAllControllers

Posted: Sat Sep 07, 2024 4:23 pm
by altren