AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Server Crashing [Sourcehook RecallGetIFace] (https://forums.alliedmods.net/showthread.php?t=88967)

CrimsonGT 03-31-2009 08:08

Server Crashing [Sourcehook RecallGetIFace]
 
So this just started happening tonight and im not sure why as I havent really changed anything at all. The few additions I did make were totally unrelated, didnt use Sourcehook at all, and I removed them and its still occuring.

The problem seems to be with my prehook on LevelInit() however its been there for months and hasnt caused any problems. The exact line I dont think it likes is...

SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, char const *, char const *, char const *, char const *, bool, bool);

but as I said before, until now its worked perfectly. Nothing massive has changed in the least so this is extremely odd. Heres a picture of the callstack trace, and so on.

http://imagenouch.com/images/2009/Mar/11238501157.PNG

Keeper 03-31-2009 08:59

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Looks like ( and I'm no real expert here ) that your sourcehook pointer isn't set.

Looks like the error comes from the shptr->GetIfacePtr()

CrimsonGT 03-31-2009 09:17

Re: Server Crashing [Sourcehook RecallGetIFace]
 
I dunno, still not sure how that could have happened as everything has been working fine. Not to mention it adds various hooks prior to that one.

BAILOPAN 03-31-2009 11:56

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Yeah, the SMSDK sets the shptr pointer for you. Though just to be sure you can always inspect it with the debugger.

CrimsonGT 03-31-2009 12:23

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Yeah it seems to be fine, so I am still clueless. Ive been tinkering for hours and cannot figure out what the problem is.

Keeper 03-31-2009 13:38

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Seems something there is null. Maybe the definition of your IServerGameDLL variable??? Be my next guess.

PM 03-31-2009 16:57

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Mhhh, that call stack looks weird.
At the bottom engine.dll calls LevelInit
Then the hookfunc in metamod.2.ep2.dll gets called (because the metamod core is the first thing that registered a hook on LevelInit)
It first calls your PreHook handler over CMyDelegateImpl and FastDelegate.
Why does it jump back into metamod...dll ? Your handler function should be there instead.
Then some bogus address and then RecallGetIface. RecallGetIface will probably be correct if you're doing RETURN_META_(..)NEWPARAMS but the jump from FastDelegate into metamod.dll and then into an address which seems to be on the heap looks like the stack might have been corrupted.

Or I'm wrong, I'm tired, I'll take another look tomorrow.
Would you mind sharing some code? Your LevelInit handler might help a bit.

CrimsonGT 03-31-2009 17:02

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Certainly, I appreciate the help.

Code:

char *g_MapEntLists; //Stores list of all Map Entities on LevelInit()

//-----------------------------------------------------------------------------
// Purpose: Get the list of Map Entities before they are all created in the
// server and insert our own entities into the map we need.
//-----------------------------------------------------------------------------
bool TF2RocketArena::Hook_LevelInit(const char *pMapName,
                                char const *pMapEntities,
                                char const *pOldLevel,
                                char const *pLandmarkName,
                                bool loadGame,
                                bool background)
{
    //If the Server is running clan arena mode
    if(g_ClanArenaMode.GetInt() == 1)
    {
        char strArenaLogic[255] = "{ \"CapEnableDelay\" \"600\" \"classname\" \"tf_logic_arena\" }";

        size_t StrEntLen = strlen(pMapEntities) + strlen(strArenaLogic) + 64;
        g_MapEntLists = new char [StrEntLen];

        strcpy(g_MapEntLists, pMapEntities);
        strcat(g_MapEntLists, strArenaLogic);

        RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, true, &IServerGameDLL::LevelInit, (pMapName, g_MapEntLists, pOldLevel, pLandmarkName, loadGame, background));
    }

    RETURN_META_VALUE(MRES_IGNORED, NULL);
}


PM 04-01-2009 11:22

Re: Server Crashing [Sourcehook RecallGetIFace]
 
Mmm, I don't see anything wrong. Have you tried to put that hook alone in a separate test plugin?


Another problem with that callstack is:
RETURN_META_VALUE_NEWPARAMS calls:

SH_GLOB_SHPTR->SetRes
SH_GLOB_SHPTR->DoRecall
SH_GLOB_SHPTR->GetIface
in that order.

So if shptr was null it should crash on the first one.

Keeper 04-01-2009 12:26

Re: Server Crashing [Sourcehook RecallGetIFace]
 
In his .png tho, the shptr is null in the call stack. That just doesn't make sense on why it would be that way.


All times are GMT -4. The time now is 17:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.