nosoop / SM-TFCustomWeaponsX

SourceMod plugin that allows players to use custom TF2 items.
GNU General Public License v3.0
22 stars 11 forks source link

"ED_Alloc no free edicts" crash when refunding credits in MvM. #42

Open Gamepro5 opened 2 years ago

Gamepro5 commented 2 years ago

Environment

Description

When clicking the "refund" button in mvm, the server crashes and reports "ED_Alloc no free edicts". This does not happen if this plugin is not installed. Screenshot 2022-07-12 233955

Steps to replicate

  1. Place this file in the configs/cwx folder. (generated using this)
  2. Load up a game of mvm_ghost_town.
  3. Click the refund credits button.

Other information

sm exts list; sm plugins list;
[SM] Displaying 10 extensions:
[01] Automatic Updater (1.11.0.6906): Updates SourceMod gamedata files
[02] Webternet (1.11.0.6906): Extension for interacting with URLs
[03] TF2 Tools (1.11.0.6906): TF2 extended functionality
[04] BinTools (1.11.0.6906): Low-level C/C++ Calling API
[05] SDK Hooks (1.11.0.6906): Source SDK Hooks
[06] SDK Tools (1.11.0.6906): Source SDK Tools
[07] Top Menus (1.11.0.6906): Creates sorted nested menus
[08] Client Preferences (1.11.0.6906): Saves client preference settings
[09] SQLite (1.11.0.6906): SQLite Driver
[10] DHooks (1.11.0.6906): Dynamic Hooks
[SM] Listing 27 plugins:
  01 "Admin File Reader" (1.11.0.6906) by AlliedModders LLC
  02 "Admin Help" (1.11.0.6906) by AlliedModders LLC
  03 "Admin Menu" (1.11.0.6906) by AlliedModders LLC
  04 "Anti-Flood" (1.11.0.6906) by AlliedModders LLC
  05 "Basic Ban Commands" (1.11.0.6906) by AlliedModders LLC
  06 "Basic Chat" (1.11.0.6906) by AlliedModders LLC
  07 "Basic Comm Control" (1.11.0.6906) by AlliedModders LLC
  08 "Basic Commands" (1.11.0.6906) by AlliedModders LLC
  09 "Basic Info Triggers" (1.11.0.6906) by AlliedModders LLC
  10 "Basic Votes" (1.11.0.6906) by AlliedModders LLC
  11 "Client Preferences" (1.11.0.6906) by AlliedModders LLC
  12 "[TF2CA] Custom Weapons Config Adapter for Custom Attributes" (1.2.2) by nosoop
  13 "[TF2] Custom Weapons X" (X.0.10-006b99b) by nosoop
  14 "[TF2] Custom Weapons X - Equip Commands" (1.1.0) by nosoop
  15 "Fun Commands" (1.11.0.6906) by AlliedModders LLC
  16 "Fun Votes" (1.11.0.6906) by AlliedModders LLC
  17 "Nextmap" (1.11.0.6906) by AlliedModders LLC
  18 "Player Commands" (1.11.0.6906) by AlliedModders LLC
  19 "Reserved Slots" (1.11.0.6906) by AlliedModders LLC
  20 "Sound Commands" (1.11.0.6906) by AlliedModders LLC
  21 "[TF2] TF2Attributes" (1.3.3@nosoop-1.7.1.1) by FlaminSarge
  22 "TF2 Utils" (0.19.1) by nosoop
  23 "[TF2] Custom Attributes" (0.4.1) by nosoop
  24 "[TF2] Custom Attribute Debugger" (1.0.0) by nosoop
  25 "[TF2] Custom Attribute Manager" (1.0.0) by nosoop
  26 "[TF2] Custom Attribute Team Subsection Handler" (1.1.0) by nosoop
  27 "[TF2] Econ Data" (0.18.2) by nosoop
nosoop commented 2 years ago

Managed to reproduce this while refunding with the custom Scout secondary / melee equipped on any MvM map.

I think I've seen this one before — what's happening is that at least one or more of the attributes being applied matches one of the upgrades available in MvM.

The upgrade system uses the same "runtime attribute" functionality that CWX (or rather, the underlying TF2Attributes) uses, and for some reason the game has a really slow path of iterating through each upgrade step even if it extends past the limit of what the game normally supports; in your config I think the critboost, clip size, and maybe max health bonuses match one of the game's existing upgrades.

For each upgrade step it respawns the player and revalidates their loadout, so as you can guess, having something like +99900% ammo capacity being upgraded in +50% increments is painfully slow. (I suspect something similar is what's causing players to get ejected from MvM during refunds with the recent net_chan_limit_msec changes, just at a smaller scale.)

Edicts are only swept at one point in each game tick, and each respawn causes a new weapon to be generated, which is what leads up to the crash.

This isn't specific to CWX, but I suspect that if this doesn't affect CW3, it's because items are reapplied instead of persisted. Hard to tell for sure though.

The current workaround is to use an attribute name that doesn't match one of the game's upgrades (using an attribute with the same attribute class). If one doesn't exist, you can create one using a schema injecting-method such as Hidden Dev Attributes. The benefit of this method is that any upgrades recognized on the client for that item won't cause the game to crash (the UI will also try to draw an unbounded number of upgrade steps).

Leaving this open since this is a valid issue; however I can't guarantee that I'll have a fix for this. I'm hearing the "slow upgrade step" logic is going to be optimized since it does cause issues with the recent changes mentioned, so we may just see if it gets fixed that way.

I've also added a note for this in the getting started / item creation page.