Skip to content

Fix: properly check disabled items against segfaults#868

Open
metaq3 wants to merge 1 commit intoioquake:mainfrom
metaq3:meta/fix/properly-check-disabled-items
Open

Fix: properly check disabled items against segfaults#868
metaq3 wants to merge 1 commit intoioquake:mainfrom
metaq3:meta/fix/properly-check-disabled-items

Conversation

@metaq3
Copy link
Copy Markdown

@metaq3 metaq3 commented May 6, 2026

The issue

I'm using native libraries. On some maps that have "teamed" items, where some of them are disabled through disable_<item> cvar, there's always a chance of the server crashing with SIGSEGV. Using give command to obtain disabled item also leads to segmentation violation.

Qvm on that matter just spawns nothing until the end of the match, but using give command will still crash the game.

Reliable way to reproduce

Build native libraries and copy them into baseq3.

Map q3ctf3 has "teamed" items at the center of the map ( quad, regeneration and invisibility, which are chosen randomly on powerup respawn ). Disable regeneration and invisibility.

Here's command to start such server:

./ioquake3 +set sv_pure 0 +set vm_game 0 +devmap q3ctf3 +set disable_item_regen 1 +set disable_item_invis 1

Restart the map with map_restart, go to the center of the map, where powerups are spawned, and pickup quad until the server crashes. I sped up the game with sv_fps 250 and timescale 100, so I can observe crash within 10 seconds after standing at one place.

The fix

When an item is disabled, any entity of that item will have nullish ent->item. Currently, I check for this as another spawning condition ( until forceSpawn is set ). Making it so requires user to restart the map each time they disable/enable items on the server, which is vanilla behaviour, but I would personally suggest against requiring map restart to apply the changes. As I see, it can be done by checking every couple of ticks whether an item has been enabled to spawn it or to prevent it from spawning if it has been disabled. It would also make code cleaner, as G_ItemDisabled says more to the reader than !ent->item check.

But still, waiting for your opinions and review. Would be glad to get any!

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.

1 participant