Skip to content

Fix: properly check for item disable status against segfault#72

Closed
metaq3 wants to merge 2 commits into
ec-:masterfrom
metaq3:meta/fix/team-item-respawn
Closed

Fix: properly check for item disable status against segfault#72
metaq3 wants to merge 2 commits into
ec-:masterfrom
metaq3:meta/fix/team-item-respawn

Conversation

@metaq3

@metaq3 metaq3 commented May 4, 2026

Copy link
Copy Markdown

Trivia

I have a teamplay server with g_gametype 3 and some items disabled through disable_<item> cvars. I noticed, that on some maps my server was randomly crashing with SIGSEGV ( I'm using native libraries ).

This is really rare bug. I found only one way to reproduce it with guaranteed result.

Reliable way to reproduce

Build native libraries and copy them into baseq3. Download map "battleforged" ( battleforged.zip ) and make a simple config, which disables a bunch of items and adds some bots:

disable.cfg
set disable_weapon_gauntlet 1
set disable_weapon_shotgun 1
set disable_weapon_machinegun 1
set disable_weapon_grenadelauncher 1
set disable_weapon_rocketlauncher 1
set disable_weapon_lightning 1
set disable_weapon_railgun 1
set disable_weapon_plasmagun 1
set disable_weapon_bfg 1
set disable_ammo_shells 1
set disable_ammo_bullets 1
set disable_ammo_grenades 1
set disable_ammo_cells 1
set disable_ammo_lightning 1
set disable_ammo_rockets 1
set disable_ammo_slugs 1
set disable_ammo_bfg 1
set disable_item_armor_shard 1
set disable_item_armor_combat 1
set disable_item_armor_body 1
set disable_item_health_small 1
set disable_item_health 1
set disable_item_health_large 1
set disable_item_health_mega 1
set disable_item_quad 1

addbot Xaero 5
addbot Xaero 5
addbot Xaero 5
addbot Xaero 5
addbot Xaero 5
addbot Xaero 5
addbot Xaero 5

Start a server through command line:

./q3ded +set sv_pure 0 +set vm_game 0 +devmap battleforged +set g_gametype 3 +exec disable.cfg

After connecting to a server, restart the map through map_restart and wait, untill it crashes. I sped up game with timescale 100 and sv_fps 250, so I can observe crash after about 10 seconds of watching bots playing.

Why it's crashing

When an item is disabled through a cvar, the item field of gentity_t is left NULL. RespawnItem wants to respawn an item and tries to dereference nullish ent->item, which leads to segmentation violation. This is also true for "teamed" items, where a random picked item from the "team" could be disabled, thus have nullish ent->item.

metaq3 added 2 commits May 4, 2026 21:43
Item disabling with team gametypes no more leads to segfault on native
builds, items respawn correctly.
@ec-

ec- commented May 6, 2026

Copy link
Copy Markdown
Owner

fixed in 9503efa

@ec- ec- closed this May 6, 2026
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.

2 participants