Skip to content

[Crash] Intermittent but deterministic pre-save crash in single-threaded mode (vector too long) #1593

Description

@51812180-gif

The Bug

The server is configured with a strict 30-minute SavePeriod. It never survives longer than 24 hours (approx. 48 save cycles). Whenever the crash occurs, it happens exactly ~1 second before the 30-minute save trigger executes. It never crashes at any other time outside of this pre-save window.

Environment & Constraints

  • OS: Windows Server 2022 (64-bit)
  • Sphere Version: Latest Source-X dev branch
  • Threading: Strictly single-threaded (NetworkThreads=0). NetworkThreads=1 causes immediate, severe, and continuous crashes in my environment and is completely unusable.
  • Load: Early-stage server with single-digit player count.
  • Scripts: [FUNCTION f_onserver_save] is completely empty. No custom scripts interfere.

Critical Facts

  1. Strictly Tied to Save Cycle: The crash is exclusively bound to the 30-min save timer. If I change the SavePeriod, the crash timing shifts accordingly. It is 100% deterministic relative to the save trigger, but intermittent across save cycles (sometimes survives a few cycles, never exceeds 24h).
  2. No Script Interference: The empty save trigger and low player count completely rule out script logic errors or high-load/OOM issues.

The Log

CRITICAL:ExcType=std::exception catched in SUB: CWorldTicker::Update main list() ("")
CRITICAL:exception.what(): vector too long

Immediately followed by a hard crash as CWorld::Save() begins.

What I Have Tried (Failed)

I patched src/game/CWorld.cpp locally (nullifying UID slots before delete in GC, adding re-entrancy guards in Save()). General stability improved, but this specific pre-save crash persists. I lack the engine-level expertise to trace the state-dependent memory corruption happening right before the save executes in single-threaded mode.

Request for Maintainers

Given that NetworkThreads=1 is not an option for me, and this crash is strictly locked to the pre-save window of a 30-min cycle in a low-load single-threaded environment on Windows Server 2022 x64:

  1. What specific single-threaded code path executed right before CWorld::Save() could accumulate stale state over multiple save cycles and corrupt CWorldTicker's vector?
  2. Are there any single-thread safe ini flags or workarounds to bypass this pre-save state transition?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions