Skip to content

Add syscall overflow detection to prevent VM infinite loops#371

Merged
ec- merged 1 commit intoec-:mainfrom
runlevel5:fix-vm-syscall-overflow
Feb 12, 2026
Merged

Add syscall overflow detection to prevent VM infinite loops#371
ec- merged 1 commit intoec-:mainfrom
runlevel5:fix-vm-syscall-overflow

Conversation

@runlevel5
Copy link
Contributor

Summary

  • Adds a per-VM_Call() syscall counter that detects infinite loops in QVM code, preventing the server from hanging at 100% CPU
  • The counter resets at each top-level VM_Call() invocation and triggers Com_Error(ERR_DROP, ...) after 1,000,000 syscalls
  • This is a general safety improvement consistent with existing vm_rtChecks infrastructure

Motivation

The stock id Software 1.32 qagame.qvm (from pak8.pk3) has an infinite loop bug in ClientSpawn() that causes the server to hang when all spawn points would telefrag (reproducible with 8+ bots on small maps like cpm30_b1). ioquake3 fixed this in the game code (commit f5d79ea), but since Quake3e is engine-only and ships no QVMs, the fix must be engine-side.

See #370 for full root cause analysis and test results.

Changes

File Change
code/qcommon/vm_local.h Add syscallCount field to vm_t struct
code/qcommon/vm.c Reset counter at start of top-level VM_Call()
code/server/sv_game.c Increment counter and check threshold in SV_GameSystemCalls()

Testing

Test Result
7 bots on cpm30_b1 (below trigger) All bots spawn and fight normally, no overflow
8 bots on q3dm17 (large map) All 8 bots active, no false positive
8 bots on cpm30_b1 (triggers bug) Overflow detected, server shuts down cleanly instead of hanging

Fixes #370

The stock id 1.32 qagame.qvm has a bug in ClientSpawn() where a
do/while(1) loop retrying spawn point selection can loop forever
if all spawn points would telefrag and the fallback has FL_NO_BOTS
set, causing the server to hang at 100% CPU.

Since Quake3e is engine-only and ships no QVMs, add a general-purpose
syscall counter that resets at each top-level VM_Call() and errors out
after 1,000,000 syscalls, consistent with existing vm_rtChecks safety
infrastructure.

Fixes ec-#370
@runlevel5 runlevel5 marked this pull request as draft February 11, 2026 01:56
@runlevel5 runlevel5 marked this pull request as ready for review February 11, 2026 06:01
@ec- ec- merged commit 502846e into ec-:main Feb 12, 2026
28 checks passed
@runlevel5 runlevel5 deleted the fix-vm-syscall-overflow branch February 12, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server hangs at 100% CPU with stock id 1.32 qagame.qvm when all spawn points would telefrag (8+ bots on small maps)

2 participants