Summary
On an ARM64 cloud host (Ampere A1, Ubuntu 22.04.5 aarch64) running CS2 via FEX-Emu, CounterStrikeSharp loads cleanly and plugins register/initialize fine, but globals::entitySystem stays nullptr for the lifetime of the process. Every entity-touching API call from plugin event handlers throws:
CounterStrikeSharp.API.Core.NativeException: Entity system yet is not initialized
at CounterStrikeSharp.API.Core.NativeAPI.GetConcreteEntityListPointer() in .../Generated/Natives/API.cs:line 983
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
...
at RetakesPlugin.Utils.PlayerHelper.IsValid(CCSPlayerController player)
at RetakesPlugin.Events.PlayerEventHandlers.OnPlayerSpawn(EventPlayerSpawn event, GameEventInfo info)
What proves this is the entity-system init bug, not a plugin bug
- Static plugin init works:
[Retakes 3.0.4 - QueueManager] Queue manager initialized (Max: 9, T Ratio: 0.45) fires correctly on map start
- CSS native init works:
CSSharp: Globals loaded / CSSharp: Initialized GameSystem / CSSharp: Hooks added all log on boot
- The exception only fires on player-event handlers that traverse the entity system
- Source location:
src/mm_plugin.cpp Hook_StartupServer is the only place that sets globals::entitySystem via interfaces::pGameResourceServiceServer->GetGameEntitySystem(). Either the hook never fires or GetGameEntitySystem() returns nullptr.
Environment
- Host: Ampere A1 (4-OCPU aarch64 cloud VM), Ubuntu 22.04.5 LTS
- CPU: ARM Cortex-A78 (CPU implementer 0x41)
- CS2: buildid
23371447 (1.41.6.4/14164, public branch, last server-side update May 22 2026)
- Runner: FEXInterpreter binary dated May 22 2026
- Metamod: 2.0.0-dev+1401, built May 4 2026 from
efeabcf
- CSS tested: stock v1.0.368 (md5
6d7386639b23c0945f0308de5db9e614) AND mrc4tt/CounterStrikeSharp v1.0.384 (md5 0ac7189b22ea49778305f76a94cd3b77) — both reproduce the same bug
- Plugins: RetakesPlugin 3.0.4 (B3none), RetakesAllocator 2.4.2 (yonilerner), NoFallZone 1.2 — all show
LOADED in css_plugins list
- DOTNET env:
DOTNET_EnableWriteXorExecute=0 set
Critical timing detail
The SAME binaries and SAME CS2 buildid were running cleanly approximately 20 hours before the bug appeared:
- May 23 02:01 UTC —
[Retakes 3.0.4 - QueueManager] Queue manager initialized + Force added bot Jaques to active players + OnPlayerHurt event with entitySystem populated — fully working
- May 23 22:25 UTC — first
Entity system yet is not initialized exception
- The only intervening action was
systemctl restart cs2-2.service
- CS2 buildid was
23371447 both before and after the restart (verified from journal logs at both timestamps)
This rules out a CS2 binary update as the cause. Something in the boot path is intermittent, and the working state was apparently lucky.
Reproduction
- CS2 dedicated server on aarch64 + FEX-Emu, public 1.41.6.4
- CSS v1.0.368 with-runtime
- RetakesPlugin 3.0.4 + RetakesAllocator 2.4.2 + any plugin that calls entity APIs
systemctl start cs2.service
bot_add via RCON
- Journal floods with
Entity system yet is not initialized from every event handler
What we tried that did NOT help
- CS2 downgrade to build
23241720 (1.41.6.1) via Steam beta pin — same errors
- Complete wipe of
addons/counterstrikesharp/, fresh extraction from upstream zip — same errors
- Fork:
mrc4tt/CounterStrikeSharp v1.0.384 (May 24 2026, contains "Hook_StartupServer against spurious second call" patch) — same errors
changelevel via RCON to retrigger StartupServer — same errors
- Two sequential
changelevel calls to different maps — same errors
- 3 fresh
systemctl restart cs2.service cycles — deterministic 12-error count on each successful boot (one SEGV'd on shutdown)
- All
DOTNET_* flags applied per ARM/FEX docs
Likely root cause
Metamod's SourceHook installs a hook on INetworkServerService::StartupServer via x86_64 trampolines. FEX-Emu's translation layer may not handle the trampoline insertion or the subsequent invocation reliably, causing the hook to silently fail to fire (or fire with a context where pGameResourceServiceServer is nullptr).
The cs2-signatures tracker shows CSS as ✅ on Linux because tests are on native x86_64. The bug is specific to the FEX-translated environment.
Asks
- Can
globals::entitySystem be initialized from a later/different hook point (e.g., first OnFrame, or via InitGameSystem lazy lookup) to avoid relying on SourceHook trampolines?
- Could CSS add a log line on Hook_StartupServer entry and on
interfaces::pGameResourceServiceServer resolution so we can confirm which step fails under FEX?
- Any known SourceHook configuration that's more FEX-friendly?
Happy to provide further logs, gdb stacks, or test patches.
Summary
On an ARM64 cloud host (Ampere A1, Ubuntu 22.04.5 aarch64) running CS2 via FEX-Emu, CounterStrikeSharp loads cleanly and plugins register/initialize fine, but
globals::entitySystemstaysnullptrfor the lifetime of the process. Every entity-touching API call from plugin event handlers throws:What proves this is the entity-system init bug, not a plugin bug
[Retakes 3.0.4 - QueueManager] Queue manager initialized (Max: 9, T Ratio: 0.45)fires correctly on map startCSSharp: Globals loaded/CSSharp: Initialized GameSystem/CSSharp: Hooks addedall log on bootsrc/mm_plugin.cppHook_StartupServeris the only place that setsglobals::entitySystemviainterfaces::pGameResourceServiceServer->GetGameEntitySystem(). Either the hook never fires orGetGameEntitySystem()returns nullptr.Environment
23371447(1.41.6.4/14164, public branch, last server-side update May 22 2026)efeabcf6d7386639b23c0945f0308de5db9e614) ANDmrc4tt/CounterStrikeSharpv1.0.384 (md50ac7189b22ea49778305f76a94cd3b77) — both reproduce the same bugLOADEDincss_plugins listDOTNET_EnableWriteXorExecute=0setCritical timing detail
The SAME binaries and SAME CS2 buildid were running cleanly approximately 20 hours before the bug appeared:
[Retakes 3.0.4 - QueueManager] Queue manager initialized+Force added bot Jaques to active players+OnPlayerHurtevent with entitySystem populated — fully workingEntity system yet is not initializedexceptionsystemctl restart cs2-2.service23371447both before and after the restart (verified from journal logs at both timestamps)This rules out a CS2 binary update as the cause. Something in the boot path is intermittent, and the working state was apparently lucky.
Reproduction
systemctl start cs2.servicebot_addvia RCONEntity system yet is not initializedfrom every event handlerWhat we tried that did NOT help
23241720(1.41.6.1) via Steam beta pin — same errorsaddons/counterstrikesharp/, fresh extraction from upstream zip — same errorsmrc4tt/CounterStrikeSharpv1.0.384 (May 24 2026, contains "Hook_StartupServer against spurious second call" patch) — same errorschangelevelvia RCON to retrigger StartupServer — same errorschangelevelcalls to different maps — same errorssystemctl restart cs2.servicecycles — deterministic 12-error count on each successful boot (one SEGV'd on shutdown)DOTNET_*flags applied per ARM/FEX docsLikely root cause
Metamod's SourceHook installs a hook on
INetworkServerService::StartupServervia x86_64 trampolines. FEX-Emu's translation layer may not handle the trampoline insertion or the subsequent invocation reliably, causing the hook to silently fail to fire (or fire with a context wherepGameResourceServiceServeris nullptr).The cs2-signatures tracker shows CSS as ✅ on Linux because tests are on native x86_64. The bug is specific to the FEX-translated environment.
Asks
globals::entitySystembe initialized from a later/different hook point (e.g., firstOnFrame, or viaInitGameSystemlazy lookup) to avoid relying on SourceHook trampolines?interfaces::pGameResourceServiceServerresolution so we can confirm which step fails under FEX?Happy to provide further logs, gdb stacks, or test patches.