Skip to content

Conversation

@heymykola
Copy link
Contributor

@heymykola heymykola commented Jan 31, 2026

This is a follow-up to PR #2397. While the IClient/netchan guard fixed the original crash, the server still crashes during CPlayer::Initialize() at the UpdateAuthIds() call. The issue is that UpdateAuthIds() reads gamedata via g_pGameConf, which is not guaranteed to be available on some Source 2007–based engine forks. This adds a small guard so missing gamedata is treated as unset instead of causing an access violation.

Prevent crash on Source 2007 forks where GetPlayerNetInfo()->GetMsgHandler() is not compatible with IClient.

Only attempt the netchan/IClient path for known-safe game folders; otherwise leave m_pIClient null.
his is a follow-up to PR alliedmodders#2397 (Guard IClient Netchan Path by Gamedata). While that change prevents the netchan crash, testing on Source 2007–based forks showed the server can still crash during early client initialization when gamedata is accessed before it’s available. This adds a small guard around g_pGameConf key lookups so missing gamedata is treated as “unset,” preserving default behavior while preventing an access violation.
@heymykola
Copy link
Contributor Author

heymykola commented Feb 1, 2026

Crash ID: N66Z-JZGG-6QEI

sourcemod.2.ep2.dll!CPlayer::Initialize(char const *,char const *,edict_t *) [PlayerManager.cpp:2062 + 0x7] 

sourcemod.2.ep2.dll!PlayerManager::OnClientConnect(edict_t *,char const *,char const *,char *,int) [PlayerManager.cpp:518 + 0x10] 

sourcemod.2.ep2.dll!__SourceHook_FHCls_IServerGameClientsClientConnect0::Func(edict_t *,char const *,char const *,char *,int) [PlayerManager.cpp:71 + 0x89]

1.4.8 and 1.5.2 were the last SM versions that worked on Kuma, because they didn’t depend on gamedata/Steam-ID plumbing at connect time. My concern if these two lines are merged is I don't know yet if inside UpdateAuthIds(), there are calls that could crash of Kuma's engine returns invalid pointer or string.

Copy link
Member

@Kenzzer Kenzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to need clarification on what you meant by

via g_pGameConf, which is not guaranteed to be available on some Source 2007–based engine forks

g_pGameConf is absolutely available by the time the hook on IServerGameClients::ClientConnect. The only reason it wouldn't be is if the file was missing.

Loaded here as sourcemod boots up :

void GameConfigManager::OnSourceModStartup(bool late)
{
m_gameBinPathManager.Init();
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);

Retrieved here as sourcemod initializes itself :
g_pGameConf = logicore.GetCoreGameConfig();
sCoreProviderImpl.InitializeHooks();
/* Notify! */
pBase = SMGlobalClass::head;
while (pBase)
{
pBase->OnSourceModAllInitialized();

Definitively available by the time OnSourceModAllInitialized is invoked and the hook gets setup.
void PlayerManager::OnSourceModAllInitialized()
{
SH_ADD_HOOK(IServerGameClients, ClientConnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientConnect), false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants