Skip to content

globals::entitySystem never populated by Hook_StartupServer under FEX-Emu on ARM — same CS2 buildid was working hours earlier #1320

Description

@chaos666agent

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

  1. CS2 dedicated server on aarch64 + FEX-Emu, public 1.41.6.4
  2. CSS v1.0.368 with-runtime
  3. RetakesPlugin 3.0.4 + RetakesAllocator 2.4.2 + any plugin that calls entity APIs
  4. systemctl start cs2.service
  5. bot_add via RCON
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions