[Bug]: Heap corruption / deterministic `free(): invalid pointer` crash in PlayerManager destructor on shutdown (SDK2013 engine target)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- game-dev
Direzione di ricerca
Inizia da PlayerManager::OnClientConnect(), dove m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client; scrive senza controllare il valore restituito; confrontalo con il guard aggiunto a InvalidatePlayer() nel commit 8c380e4 (issue #1107). Applica lo stesso controllo di limiti/-1 lì, poi ricostruisci il target sdk2013 e conferma che lo spegnimento con MALLOC_CHECK_=3 non interrompe più in PlayerManager::~PlayerManager(). Controlla prima il thread di commenti esistente per le indicazioni dei maintainer sull'ambito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- I have checked that my issue doesn't exist yet in the issue tracker
Operating System and Version
Ubuntu 24
Game / AppID and Version
Source SDK Multiplayer
SourceMod Version
Newest stable
Metamod:Source Version
Newest Stable
Version Verification
- I have updated SourceMod to the latest version and the issue persists
- I have updated SourceMod to the latest snapshot and the issue persists
- I have updated Metamod:Source to the latest snapshot and the issue persists
Updated SourceMod Version
1.12 - build 7253
Updated Metamod:Source Version
.12 - build 1226:
Description
SourceMod Version
1.12.0.7253 (stock build, sourcemod.2.sdk2013.so)
Description of the problem
On every clean server shutdown/restart (quit, +restart), the server deterministically crashes with:
free(): invalid pointer
Steps to Reproduce
This happens even with zero third-party plugins loaded (clean SourceMod install, only Core) and zero players connected at the time of shutdown. Reproduced with MALLOC_CHECK_=3 set, which confirms this is a genuine invalid/corrupted heap pointer, not a random race.
Backtrace (gdb, no debug symbols but resolved dynamic symbols)
#0 abort () from libc.so.6
#1 ?? () from libc.so.6
#2 ?? () from libc.so.6
#3 ?? () from libc.so.6
#4 free () from libc.so.6
#5 operator delete(void*) () from libstdc++.so.6
#6 operator delete () from libstdc++.so.6
#7 PlayerManager::~PlayerManager () from sourcemod.2.sdk2013.so
#8 __cxa_finalize () from libc.so.6
#9 __do_global_dtors_aux () from sourcemod.2.sdk2013.so
...
#19 UnloadInterface_MMS () from sourcemod_mm_i486.so
#20 Unloader::ReadyToUnload(int) () from metamod.2.sdk2013.so
...
#29 SV_ShutdownGameDLL () from engine_srv.so
The crash occurs on the second delete[] call inside PlayerManager::~PlayerManager() during the global destructor chain triggered by dlclose() on module unload.
Suspected root cause
This looks structurally identical to the historically fixed issue #1107 (unchecked -1 return of engine->GetPlayerUserId() writing out of bounds into m_UserIdLookUp, corrupting the heap chunk header, with the crash surfacing much later at free()).
That specific instance (in InvalidatePlayer()) was fixed in commit 8c380e4 (Oct 2019). However, the same unchecked pattern still exists in PlayerManager::OnClientConnect():
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client;
No bounds/-1 check is performed here, same as the originally reported bug. Given this reproduces 100% deterministically on a custom SDK2013-based mod (non-standard edict/userid handling), it's plausible this specific engine target hits the -1 edge case reliably where stock games rarely do.
Suggested fix
Apply the same guard as in the #1107 fix:
int userid = engine->GetPlayerUserId(pEntity);
if (userid >= 0 && userid <= USHRT_MAX)
{
m_UserIdLookUp[userid] = client;
}
Environment
- Engine target: SDK2013 (custom mod, "sgm_beta")
- OS: Linux (i386/x86 32-bit binaries)
- Reproducible on every shutdown, independent of player count/session activity
Relevant Log Output
- Lingua principale
- C++
- Stelle
- 1.2k
- Fork
- 476
- Merge medio
- 2g 9h
- PR unite (30g)
- 13
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di alliedmodders/sourcemod
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Forse già presa @fmu1337 l’ha presa oggi. ApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
alliedmodders/sourcemod#2627 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
alliedmodders/sourcemod#2615 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
alliedmodders/sourcemod#2613 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Disable Nextmap for CSGO?ApertaFeature Request
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 64/100
alliedmodders/sourcemod#2555 · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
alliedmodders/sourcemod#2625 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di alliedmodders/sourcemod
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
patrick-hudson/put.gd-desktop#2044 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
uxlfoundation/oneDNN#6604 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
lballabio/QuantLib#3134 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni