FortyTwoFortyTwo / Randomizer

TF2 plugin that randomizes player loadout in any imaginable combinations
GNU General Public License v3.0
35 stars 16 forks source link

Entities are not cleaned up after a bot's death, eventually leading to an edict overflow #9

Closed sappykun closed 4 years ago

sappykun commented 4 years ago

Problem: This plugin seems to leave certain entities alive after a bot's death. Since these are not cleaned up, the server eventually hits the entity limit of 2047 and crashes. Reproduction steps: Introduce bots into the game while the plugin is loaded. Expected: Bots to suicide as usual as they try to change to their preferred class, but for the entity count to stay somewhat stable. Received: When a bot respawns, it does not remove old entities, eventually crashing the server.

I don't expect this plugin to support bots, but our community's server regularly hits 33 players. I do not know if this plugin deletes unused entities if the player is an actual human as opposed to a bot.

I have provided 3 videos of what I observed. All videos use Security Entity Limit (SEL) to count the entity limit.

Example 1

This video shows the edict count without Randomizer. I am using Force Class to force the bots to be Medic, causing them to suicide constantly. 31 bots have been spawned on both teams. The entity count never goes over 1500 in this example.

Example 2

This video shows the edict count using Randomizer. The Force Class plugin from video 1 has been removed. 31 bots have been spawned. The server crashes almost immediately in this example. SEL cannot delete the entities quick enough before the server coredumps from an edict overflow.

Example 3

This video shows the edict count using Randomizer. The Force Class plugin from video 1 has been removed. 11 bots have been spawned. The edict count starts at around 1040, then slowly crawls up as the bots suicide. Once 1900 entities have been spawned, SEL begins to clean up unused entities, bringing the count down to 1800, where it ends up constantly having to prune the entity count.

sappykun commented 4 years ago

For reference's sake, this is a video showcasing Randomizer 1.7 (Competitive update). Like the first video, it does not go over 1500 entities, even when 31 bots are spawned.

https://youtu.be/gphDK2AgmHE

FortyTwoFortyTwo commented 4 years ago

Do you have an example for list of entities count with classname when crash happens? Knowing which entity classname spawned the most can help a lot.

sappykun commented 4 years ago
L 05/26/2020 - 22:17:37: Spewing edict counts:
L 05/26/2020 - 22:17:37: (0.05%) 1  worldspawn
L 05/26/2020 - 22:17:37: (0.05%) 1  soundent
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_player_manager
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_objective_resource
L 05/26/2020 - 22:17:37: (0.05%) 1  monster_resource
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_mann_vs_machine_stats
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_gamerules
L 05/26/2020 - 22:17:37: (0.05%) 1  vote_controller
L 05/26/2020 - 22:17:37: (0.05%) 1  ai_network
L 05/26/2020 - 22:17:37: (0.05%) 1  env_tonemap_controller
L 05/26/2020 - 22:17:37: (0.05%) 1  water_lod_control
L 05/26/2020 - 22:17:37: (0.05%) 1  entity_soldier_statue
L 05/26/2020 - 22:17:37: (0.05%) 1  env_fog_controller
L 05/26/2020 - 22:17:37: (0.05%) 1  game_round_win
L 05/26/2020 - 22:17:37: (0.05%) 1  team_round_timer
L 05/26/2020 - 22:17:37: (0.05%) 1  team_control_point_master
L 05/26/2020 - 22:17:37: (0.05%) 1  shadow_control
L 05/26/2020 - 22:17:37: (0.05%) 1  path_track
L 05/26/2020 - 22:17:37: (0.05%) 1  scene_manager
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_spellbook
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_sentry_revenge
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_wearable_demoshield
L 05/26/2020 - 22:17:37: (0.05%) 1  obj_teleporter
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_buff_item
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_bat_giftwrap
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_robot_arm
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_wearable_robot_arm
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_sword
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_lunchbox_drink
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_stickbomb
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_jar
L 05/26/2020 - 22:17:37: (0.05%) 1  tf_weapon_parachute_secondary
L 05/26/2020 - 22:17:37: (0.10%) 2  env_soundscape
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_weapon_bat_fish
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_weapon_shotgun_building_rescue
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_weapon_sniperrifle_decap
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_weapon_rocketlauncher_directhit
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_weapon_compound_bow
L 05/26/2020 - 22:17:37: (0.10%) 2  tf_dropped_weapon
L 05/26/2020 - 22:17:37: (0.15%) 3  team_control_point_round
L 05/26/2020 - 22:17:37: (0.15%) 3  tf_weapon_lunchbox
L 05/26/2020 - 22:17:37: (0.15%) 3  tf_weapon_handgun_scout_secondary
L 05/26/2020 - 22:17:37: (0.20%) 4  tf_team
L 05/26/2020 - 22:17:37: (0.20%) 4  item_ammopack_small
L 05/26/2020 - 22:17:37: (0.20%) 4  func_respawnroom
L 05/26/2020 - 22:17:37: (0.20%) 4  tf_weapon_katana
L 05/26/2020 - 22:17:37: (0.20%) 4  tf_weapon_flaregun
L 05/26/2020 - 22:17:37: (0.20%) 4  tf_weapon_pda_spy
L 05/26/2020 - 22:17:37: (0.20%) 4  tf_weapon_invis
L 05/26/2020 - 22:17:37: (0.24%) 5  game_intro_viewpoint
L 05/26/2020 - 22:17:37: (0.29%) 6  team_control_point
L 05/26/2020 - 22:17:37: (0.29%) 6  trigger_capture_area
L 05/26/2020 - 22:17:37: (0.29%) 6  tf_weapon_crossbow
L 05/26/2020 - 22:17:37: (0.34%) 7  func_regenerate
L 05/26/2020 - 22:17:37: (0.34%) 7  tf_wearable
L 05/26/2020 - 22:17:37: (0.34%) 7  item_ammopack_full
L 05/26/2020 - 22:17:37: (0.34%) 7  item_healthkit_small
L 05/26/2020 - 22:17:37: (0.39%) 8  item_healthkit_medium
L 05/26/2020 - 22:17:37: (0.39%) 8  func_respawnroomvisualizer
L 05/26/2020 - 22:17:37: (0.39%) 8  tf_weapon_revolver
L 05/26/2020 - 22:17:37: (0.39%) 8  tf_weapon_knife
L 05/26/2020 - 22:17:37: (0.39%) 8  instanced_scripted_scene
L 05/26/2020 - 22:17:37: (0.44%) 9  trigger_multiple
L 05/26/2020 - 22:17:37: (0.44%) 9  info_particle_system
L 05/26/2020 - 22:17:37: (0.49%) 10 info_observer_point
L 05/26/2020 - 22:17:37: (0.49%) 10 item_healthkit_full
L 05/26/2020 - 22:17:37: (0.54%) 11 tf_weapon_scattergun
L 05/26/2020 - 22:17:37: (0.59%) 12 item_ammopack_medium
L 05/26/2020 - 22:17:37: (0.59%) 12 func_nobuild
L 05/26/2020 - 22:17:37: (0.59%) 12 ambient_generic
L 05/26/2020 - 22:17:37: (0.63%) 13 env_lightglow
L 05/26/2020 - 22:17:37: (0.63%) 13 tf_weapon_pistol_scout
L 05/26/2020 - 22:17:37: (0.68%) 14 tf_weapon_smg
L 05/26/2020 - 22:17:37: (0.68%) 14 tf_ammo_pack
L 05/26/2020 - 22:17:37: (0.68%) 14 tf_ragdoll
L 05/26/2020 - 22:17:37: (0.68%) 14 tf_weapon_bat
L 05/26/2020 - 22:17:37: (0.83%) 17 tf_weapon_pda_engineer_build
L 05/26/2020 - 22:17:37: (0.83%) 17 tf_weapon_pda_engineer_destroy
L 05/26/2020 - 22:17:37: (0.88%) 18 tf_weapon_club
L 05/26/2020 - 22:17:37: (0.98%) 20 tf_weapon_sniperrifle
L 05/26/2020 - 22:17:37: (0.98%) 20 tf_weapon_shotgun_pyro
L 05/26/2020 - 22:17:37: (1.02%) 21 prop_physics_multiplayer
L 05/26/2020 - 22:17:37: (1.02%) 21 tf_weapon_shotgun_hwg
L 05/26/2020 - 22:17:37: (1.02%) 21 tf_weapon_fists
L 05/26/2020 - 22:17:37: (1.07%) 22 func_occluder
L 05/26/2020 - 22:17:37: (1.07%) 22 tf_weapon_flamethrower
L 05/26/2020 - 22:17:37: (1.12%) 23 tf_weapon_minigun
L 05/26/2020 - 22:17:37: (1.12%) 23 move_rope
L 05/26/2020 - 22:17:37: (1.17%) 24 func_door
L 05/26/2020 - 22:17:37: (1.22%) 25 tf_weapon_rocketlauncher
L 05/26/2020 - 22:17:37: (1.22%) 25 tf_weapon_shovel
L 05/26/2020 - 22:17:37: (1.22%) 25 tf_weapon_bonesaw
L 05/26/2020 - 22:17:37: (1.22%) 25 tf_weapon_fireaxe
L 05/26/2020 - 22:17:37: (1.27%) 26 func_brush
L 05/26/2020 - 22:17:37: (1.32%) 27 tf_weapon_syringegun_medic
L 05/26/2020 - 22:17:37: (1.37%) 28 tf_weapon_shotgun_soldier
L 05/26/2020 - 22:17:37: (1.42%) 29 tf_weapon_medigun
L 05/26/2020 - 22:17:37: (1.42%) 29 tf_weapon_shotgun_primary
L 05/26/2020 - 22:17:37: (1.42%) 29 tf_weapon_pistol
L 05/26/2020 - 22:17:37: (1.51%) 31 tf_weapon_wrench
L 05/26/2020 - 22:17:37: (1.56%) 32 player
L 05/26/2020 - 22:17:37: (1.61%) 33 tf_weapon_builder
L 05/26/2020 - 22:17:37: (1.71%) 35 func_areaportal
L 05/26/2020 - 22:17:37: (1.95%) 40 tf_weapon_pipebomblauncher
L 05/26/2020 - 22:17:37: (2.05%) 42 tf_weapon_bottle
L 05/26/2020 - 22:17:37: (2.10%) 43 tf_weapon_grenadelauncher
L 05/26/2020 - 22:17:37: (2.39%) 49 env_soundscape_proxy
L 05/26/2020 - 22:17:37: (3.12%) 64 tf_viewmodel
L 05/26/2020 - 22:17:37: (3.61%) 74 keyframe_rope
L 05/26/2020 - 22:17:37: (3.81%) 78 env_sprite
L 05/26/2020 - 22:17:37: (3.90%) 80 info_player_teamspawn
L 05/26/2020 - 22:17:37: (5.03%) 103    point_spotlight
L 05/26/2020 - 22:17:37: (5.03%) 103    spotlight_end
L 05/26/2020 - 22:17:37: (5.03%) 103    beam
L 05/26/2020 - 22:17:37: (6.20%) 127    prop_dynamic
L 05/26/2020 - 22:17:37: (6.49%) 133    
L 05/26/2020 - 22:17:37: Total edicts: 2049
L 05/26/2020 - 22:17:37: Engine error: ED_Alloc: no free edicts

From the crash in the second video.

sappykun commented 4 years ago

https://pastebin.com/BvHz1PPt https://pastebin.com/DAA3MueL

A few more for comparison's sake.

Correct me if I'm wrong, but I believe point_spotlight, spotlight_end, and beam are all used by the Medic's mediguns.

FortyTwoFortyTwo commented 4 years ago

Only info_particle_system is used on medigun beam fix, 3 you mentioned is likely from cp_dustbowl.

I noticed there a lot of default weapon classname and very little non-default. 686 defaults and 42 non-defaults.

686 entities means ~21 entities for each clients in 32 player server. I imagine those entities came from bot's loadout that were somehow not deleted (not created by randomizer). Will take a look at this.

FortyTwoFortyTwo commented 4 years ago

Alright this leak affect player aswell, and only happens if TF2Items is not used. Leak happened by randomizer's dhook returning null in GiveNamedItem while still creating weapon. Try out new version i pushed, should be fixed for you.

sappykun commented 4 years ago

I was using TF2Items during my testing.

Anyways, with the latest version (1.1.0.127), edict count is now stabilized with 33 bots. Thank you for fixing this.