Add syscall overflow detection to prevent VM infinite loops#371
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VM_Call()syscall counter that detects infinite loops in QVM code, preventing the server from hanging at 100% CPUVM_Call()invocation and triggersCom_Error(ERR_DROP, ...)after 1,000,000 syscallsvm_rtChecksinfrastructureMotivation
The stock id Software 1.32
qagame.qvm(frompak8.pk3) has an infinite loop bug inClientSpawn()that causes the server to hang when all spawn points would telefrag (reproducible with 8+ bots on small maps likecpm30_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
code/qcommon/vm_local.hsyscallCountfield tovm_tstructcode/qcommon/vm.cVM_Call()code/server/sv_game.cSV_GameSystemCalls()Testing
Fixes #370