Skip to content

OverflowException in CacheManager.InitializeCacheAsync — sa_players_ips.steamid mapped to int (SteamID64 doesn't fit) #283

@playaopindo-dev

Description

@playaopindo-dev

Reopen of #264 — still reproducible on build-1.7.9a (SQLite). Root cause identified.

Stack

System.OverflowException: Arithmetic operation resulted in an overflow.
   at Deserialize<…>(DbDataReader)
   at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command)
   at CS2_SimpleAdmin.Managers.CacheManager.InitializeCacheAsync()
   at CS2_SimpleAdmin.Managers.CacheManager.InitializeCacheAsync()

Root cause

sa_players_ips.steamid is declared INTEGER and stores SteamID64 values
(e.g. 76561197989223530), which exceeds Int32.MaxValue (2147483647).
The Dapper deserializer in CacheManager.InitializeCacheAsync maps that column
to int, so it throws OverflowException on every cache init after at least
one real player has connected and SA has written a row.

Schema (head)

CREATE TABLE sa_players_ips (
    steamid INTEGER NOT NULL,
    address INTEGER NOT NULL,
    used_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    name VARCHAR(64),
    PRIMARY KEY (steamid, address)
);

Repro

Fresh SA-managed SQLite DB:

INSERT INTO sa_players_ips
VALUES (76561197989223530, 0, CURRENT_TIMESTAMP, 'x');

Next server start → OverflowException in CacheManager.InitializeCacheAsync.

Fix

The POCO / Dapper mapping for sa_players_ips.steamid (and any other steamid
columns currently typed as int server-side) needs to be long / ulong.
Same applies to address if SA ever stores IPs with the high bit set as
unsigned — currently only IPs < 128.0.0.0 happen to fit into signed int32.

Workaround for affected users

Set "CheckMultiAccountsByIp": false in CS2-SimpleAdmin.json — this skips
the failing query path. Multi-account-by-IP detection is then disabled.

Environment

  • CS2-SimpleAdmin: build-1.7.9a
  • DB: SQLite
  • Repro confirmed on a vanilla DB with a single connecting Steam account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions