简体   繁体   中英

Exception thrown at 0x00007FF746DA221B SDL_game.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF

I am trying to debug my application and I constantly receive this error and I don't know how to fix it. While debugging I found out that the place of the error is the function parseObjects. It also invokes a create function from the game object factory which is as follows ...

GameObject* GameObjectFactory::create(std::string typeID) { std::map<std::string, BaseCreator*>::iterator it = m_creators.find(typeID);

if (it == m_creators.end()) 
{
    std::cout << "could not find type: " << typeID << "\n";
    return 0;
}

BaseCreator* pCreator = (*it).second;
return pCreator->createGameObject();}

After this it invokes a Creator objects load function which loads the parameters successfully, but when it tries to push the object back into the vector it receive the up stated error.

Exception thrown at 0x00007FF746DA221B SDL_game.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

    ...
    e->Attribute("x", &x);
    e->Attribute("y", &y);
    e->Attribute("width", &width);
    e->Attribute("height", &height);
    e->Attribute("numFrames", &numFrames);
    e->Attribute("callbackID", &callbackID);
    e->Attribute("animSpeed", &animSpeed);

    type = e->Attribute("type");
    textureID = e->Attribute("textureID");

    GameObject* pGameObject = TheGameObjectFactory::Instance()->create(type);
    pGameObject->load(new LoaderParams(x, y, width, height, textureID, numFrames, callbackID, animSpeed)); 
    pObjects->push_back(pGameObject); // fails on this line ???
}`

The debugger goes to this line in vector... bool _Inside(const value_type *_Ptr) const { // test if _Ptr points inside vector return (_Ptr < this->_Mylast() && this->_Myfirst() <= _Ptr); } bool _Inside(const value_type *_Ptr) const { // test if _Ptr points inside vector return (_Ptr < this->_Mylast() && this->_Myfirst() <= _Ptr); }

Any help and suggestions will be appreciated...

我认为可能会发生这种情况,因为您的向量pObjects尚未初始化或处于某种损坏状态。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM