View Single Post
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 06-09-2021 , 15:14   Re: CSGO correct usage of manual hooks
Reply With Quote #3

I keep experiencing this crash in 5 of my extensions. I tried to dig deeper into this problem and found out that the crash only happens if an extension with either OnPlayerRunCmd or OnPostThink hooks for all players is running. For this crash to happen it is enough to have an empty hook, like this:
PHP Code:
CPlayer::CPlayer(CBaseEntityentity)
    : 
Inherited(entity)
{
    
SH_ADD_MANUALHOOK(CPlayer_PostThinkGetBaseEntity(), SH_MEMBER(this, &CPlayer::OnPostThink), true);
}

CPlayer::~CPlayer(void)
{
    
SH_REMOVE_MANUALHOOK(CPlayer_PostThinkGetBaseEntity(), SH_MEMBER(this, &CPlayer::OnPostThink), true);
}

void CPlayer::OnPostThink()
{
    
RETURN_META(MRES_IGNORED);

If I comment lines SH_ADD_MANUALHOOK and SH_REMOVE_MANUALHOOK the server stops crashing. Can it be a bug in sourcemod? If yes, then is there a way to debug it?

UPD
It turns out that Weapon_CanUse hook can also couse this crash. tripmines.ext.2.csgo.so + 0x96ebc - int __cdecl __SourceHook_MFHCls_CPlayer_Weapon_CanUse::Fu nc(int a1, int a2)

PHP Code:
CPlayer::CPlayer(CBaseEntityentity)
    : 
Inherited(entity)
{
    
SH_ADD_MANUALHOOK(CPlayer_Weapon_CanUseGetBaseEntity(), SH_MEMBER(this, &CPlayer::OnWeapon_CanUse), false);
}

CPlayer::~CPlayer(void)
{
    
SH_REMOVE_MANUALHOOK(CPlayer_Weapon_CanUseGetBaseEntity(), SH_MEMBER(this, &CPlayer::OnWeapon_CanUse), false);
}

bool CPlayer::OnWeapon_CanUse(CBaseEntitypWeapon)
{
    
RETURN_META_VALUE(MRES_IGNOREDtrue);

Attached Files
File Type: txt c8d2726a-2747-4629-70deed8c-87b17e27.dmp.txt (116.1 KB, 146 views)

Last edited by kadet.89; 06-10-2021 at 11:15.
kadet.89 is offline
Send a message via Skype™ to kadet.89