Skip to content

Release leftover collision references and stop Prey warning about Quake 4's front end - #72

Open
akacross wants to merge 2 commits into
themuffinator:mainfrom
akacross:fix-remaining-prey-warnings
Open

akacross wants to merge 2 commits into
themuffinator:mainfrom
akacross:fix-remaining-prey-warnings

Conversation

@akacross

Copy link
Copy Markdown
Contributor

Summary

Two fixes that were still missing on main after the spawn crash (#47) and the map-shutdown collision purge (#55).

  • Clip models, CheckModel, and precache LoadModel calls kept a reference on prop collision models. PurgeModels skips anything with a reference, so the 2048 slots filled during Roadhouse and the Feeding Tower and Rites of Passage (game/lotaa) failed with LoadModel: no free slots. Those loads now release the reference, and the existing purge can reuse the slot. This does not add a second FreeMap or a force flag on top of Purge collision models at each map shutdown (fixes "LoadModel: no free slots" on the fifth map of a session) #55.
  • A hitch in the settings menu queued a mouse sample the 256-event queue could not store and printed Posix_QueEvent: overflow for every extra sample. Consecutive mouse and retained-pointer samples now fold into the sample already waiting, and the overflow line is printed once per episode. Windows still reports every overflow.
  • A Prey launch warned about Quake 4 files that are not in the retail paks: the montage mask gfx/guis/mainmenu/level_edge_fade, the sound main_menu_gameplay, guis/arena_menu.gui, arena/openq4_campaign.cfg, and the chat frame images. Those lookups are skipped when the files are absent. The chat frame draws with a solid fill. Related to [Report]: Console on main d2510380: openQ4 leftovers warn at every launch and map load, and MP loads the weapon wheel after the level load (~29 ms) #69.
  • si_gameType DM is not in Prey's list (singleplayer, deathmatch, Team DM), so the cvar rewrote it to singleplayer. A listen server then loaded the single-player menus and parsed guis/hud/weapon_wheel.rui after the level load. DM is stored as deathmatch. The wheel's icons and document are read during the load, and the local player takes that parse.

Test plan

  • tools/tests/sys_event_queue_ownership.py — posix and windows, including the ten ownership mutants
  • Linux debug client, Wayland, retail Prey at ~/Games/Prey: game/roadhouse → game/feedingtowera → game/feedingtowerb → game/lotaa, each SpawnPlayer, no LoadModel: no free slots
  • spawnServer game/dmroadhouse with si_gameType DM and developer 1: multiplayer pause card, weapon wheel parse prefetched in 9 ms, MP_OK, no late non pre-cached icon warnings and no Quake 4 front-end warnings
  • Settings menu was not opened again on this binary; the posix ownership test covers the coalesce

Clip models, presence checks and precache loads kept a reference the map
shutdown purge would not drop, so the 2048 collision slots filled before
Rites of Passage. They release that reference now. A settings-menu hitch
also printed Posix_QueEvent overflow once per extra mouse sample; consecutive
motion folds into the sample already waiting, and the overflow is reported
once per episode.
A Prey launch looked up Quake 4's montage mask, menu sound, arena campaign
and chat-frame art, and warned when they were absent. Those lookups are
skipped. si_gameType DM is stored as deathmatch, so a listen server runs
deathmatch and the weapon wheel document is parsed during the level load.

@themuffinator themuffinator left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this finds real problems, and the #69 part matches that report closely. Before it can land:

  1. Please split it. It is four unrelated changes: collision-model references, the POSIX event queue, the Quake 4 front-end leftovers plus the MP weapon-wheel precache (#69), and si_gameType DM. Each needs its own review and its own bisect point. The #69 part (Session, ArenaCampaign, ChatWindow, the wheel precache, UserInterfaceRetained) is the lowest risk and can go first.

  2. Collision-model references. idClipModel never released its handle before, so a stale handle did no harm. Now ~idClipModel calls FreeModel, and for a pointer no longer in models[], FreeModel calls DestroyModel (CollisionModel_load.cpp ~707-724). Slots are replaced with DestroyModel in StoreModel and StoreProcClipModel, and FreeProcClipModels destroys proc clip models. LoadModel only adds a reference for models/ and gfx/ names, so nothing protects an inline *N or proc clip model's slot. Please show that no clip model can outlive its model through those paths, for example map change, reloadModels and savegame restore. Otherwise this is a double delete. A long map-cycling run under a debug heap (or ASan on Linux) would answer it.

  3. Event coalescing. Please use retainedUIInput_t::POINTER and read kind through the struct, not *static_cast<const int *>( ptr ) == 1.

  4. si_gameType DM. Rewriting one cvar's value by name inside idInternalCVar::UpdateValue works, but it hides the alias from everything that reads the cvar's value list. Please either gate it with HUMANHEAD and add a tools/tests check, or fix the writers (AsyncNetwork.cpp, Session.cpp ~3864, Common.cpp ~8079) to write Prey's deathmatch.

@danperisse-hue

Copy link
Copy Markdown
Contributor

I ran the long map-cycling check from point 2 under AddressSanitizer on Linux.

Build: main (5b31d56) + this PR (78fecea) + #73 (+ a test-only BitMsg stub fix), Linux x64, GCC, -Db_sanitize=address, debugoptimized.
Run: 4 laps of game/roadhouse, game/feedingtowera, game/salvage, game/lotaa, game/spindlea and game/spherebrain. After each lap it ran reloadModels, then saveGame and loadGame. That is 24 map changes, 4 reloadModels and 4 savegame restores (28 map loads), with ASAN_OPTIONS=halt_on_error=1:detect_leaks=0:quarantine_size_mb=64, so any double free or use-after-free that ASan caught on these paths would have stopped the run.

Result: no ASan report, all 28 loads finished, clean exit (status 0).

Two notes on the setup:

  • I turned off alloc_dealloc_mismatch and new_delete_type_mismatch, because two older mismatches stop ASan within the first two map changes, unrelated to this PR: idPVS::Shutdown deletes new[] arrays with delete, and idAnimManager deletes hhMD5Anim through idMD5Anim, whose destructor isn't virtual. Fix two new/delete mismatches AddressSanitizer stops on #76 fixes them.
  • The run renders with llvmpipe. On WSL's D3D12 Mesa driver the process dies inside the driver after 15 to 25 map loads, with plain main as well as with this PR, and also when only changing maps, so that isn't from this PR either.

@themuffinator

Copy link
Copy Markdown
Owner

Thanks, @danperisse-hue: that ASan run (24 map changes, 4 reloadModels, 4 save/load round trips, halting on error) answers point 2, and #76 lets the next run keep the mismatch checks on. @akacross, points 1, 3 and 4 still stand: please split the PR, use retainedUIInput_t::POINTER, and gate or move the si_gameType DM alias. The #69 part can go first.

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.

3 participants