Guard SetCSteamID When Auth String Is Invalid#2401
Guard SetCSteamID When Auth String Is Invalid#2401heymykola wants to merge 18 commits intoalliedmodders:masterfrom
Conversation
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.
|
Crash ID: N66Z-JZGG-6QEI 1.4.8 and 1.5.2 were the last SM versions that worked on Kuma, because they didn’t depend on SteamID plumbing at connect time. My concern right now is if these two lines are merged, I don't yet know if inside |
Kenzzer
left a comment
There was a problem hiding this comment.
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 :
sourcemod/core/logic/GameConfigs.cpp
Lines 1135 to 1139 in 8907569
Retrieved here as sourcemod initializes itself :
Lines 313 to 321 in 8907569
Definitively available by the time
OnSourceModAllInitialized is invoked and the hook gets setup.sourcemod/core/PlayerManager.cpp
Lines 165 to 167 in e050532
|
Gamedata loads correctly, but on the Kuma\War 2 fork an access violation occurs in CPlayer::Initialize() → UpdateAuthIds() during ClientConnect. This change would guard the g_pGameConf->GetKeyValue() reads on that path. Behavior would be unchanged on standard engines, and it prevents a crash if those reads are hit in an unexpected state on this fork. This code path did not exist in SourceMod 1.4 and earlier 1.5, where UpdateAuthIds() was not called during ClientConnect. In newer releases, this logic runs earlier during client initialization, which is where the crash occurs. In addition to the existing guards around IClient access and g_pGameConf->GetKeyValue() reads, would you prefer handling this by deferring the early UpdateAuthIds() call instead? This could follow the same pattern as the IClient netchan guard: default behavior remains unchanged, but forks where the engine state isn’t stable during ClientConnect could opt out of running UpdateAuthIds() at that point via common.games.txt? |
|
Please add some logging to the local build you used while testing this showing the initialisation order. Guards like this for our own interfaces generally look like papering over the true issue, which we're not a fan of as they seriously impact future refactoring. Don't forget to also rebase this branch on main so the build tests can run. |
|
Guards removed, logging added to each of the 3 lines crash.limetech caught - as well as OnClientConnect, CPlayer:Initialize, and UpdateAuthIds sections using the following: |
Expanding outside three logged error sections and into; * OnClientConnect: * OnClientConnect_Post: * CPlayer::Initialize: * CPlayer::UpdateAuthIds: * PlayerManager::OnSourceModStartup * PlayerManager::OnSourceModAllInitialized
|
We're not going to merge a PR that just adds logging. Asherkin meant for you to use that locally to help debugging your issue. If there really is a bug, then submit the fix. Otherwise this PR's scope as well as your initial fix are both invalid. |
|
Thank you for your patience, as I am both new to GetHub and local builds. While debugging the player-connect crash, I added logging to show through PlayerManager.cpp - and the logs showed the server crashing inside CPlayer::SetCSteamID() when engine->GetClientSteamID() was called while the auth string was still invalid. My commit adds a minimal guard to skip the SteamID query until a valid auth string is available. Behavior for normal Steam games is unchanged. I confirmed this fixes server crash on player entry after building and replacing sourcemod.2.ep2.dll. |
This is a follow-up to PR #2397. While the IClient/netchan guard resolved the initial crash, the server is still crashing during CPlayer::Initialize() at the UpdateAuthIds() call on a non-stock Source 2007 engine fork.
This change simply adds a small defensive guard to the reads performed in that path so they are treated as unset instead of triggering an access violation.