alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
989 stars 424 forks source link

[HL2MP] AcceptEntityInput(id, "Kill") causing SegFault since 20th Anniversary Update #2223

Closed Pricetx closed 1 hour ago

Pricetx commented 2 hours ago

Help us help you

Environment

Description

Hi,

So, I've been running a basic plugin I wrote 11(!) years ago on my HL2DM server. The premise is that it removes items of a particular type from a map when it first loads.

It was working fine until the 20th Anniversary update. I have updated to the latest dev builds as per the top of this post.

Since this update, whenever the AcceptEntityInput method fires off to kill the relevant items, the HL2DM server segfaults and restarts. I'll include the relevant part of the server console log below:

Set motd_text from file 'cfg/motd_text_default.txt'.  ('cfg/motd_text.txt' was not found.)
SV_ActivateServer: setting tickrate to 66.7
Found the following item entity id: 303
11/18 17:36:39 Uploading dump (in-process) [url 'https://crash.steampowered.com/submit', proxy '']
/tmp/dumps/crash_20241118173638_14.dmp
11/18 17:36:40 success = yes
11/18 17:36:40 response:  Discarded=1
Segmentation fault (core dumped)
cat: hlds.3006874.pid: No such file or directory
email debug.log to linux@valvesoftware.com
Mon 18 Nov 17:36:40 UTC 2024: Server restart in 10 seconds
Using shader api: shaderapiempty_srv.so
Using Breakpad minidump system. Version: 9353147 AppID: 232370

Below is the code for the plugin that I'm running:

Problematic Code (or Steps to Reproduce)

public Plugin:myinfo =
{
        name = "Item Remover",
        author = "Pricetx",
        description = "Item Remover",
        version = "1.0",
        url = "https://gravitygunonly.com/"
}

        new const String:itemList[][] = {
                "item_ammo_357",
                "item_ammo_ar2",
                "item_ammo_ar2_altfire",
                "item_ammo_ar2_large",
                "item_ammo_crossbow",
                "item_ammo_pistol",
                "item_ammo_pistol_large",
                "item_ammo_smg1",
                "item_box_buckshot",
                "item_item_crate",
                "item_rpg_round",
                "item_ammo_smg1_grenade"
};

public OnMapStart()
{
        RemoveItems();
}

public RemoveItems()
{
        new item = -1;

        for(new i = 0; i < sizeof(itemList); i++) {
                item = -1;
                while((item = FindEntityByClassname(item, itemList[i])) != -1) {
                        PrintToServer("Found the following item entity id: %i", item);
                        AcceptEntityInput(item, "Kill");
                }
        }
}

I added a line before the AcceptEntityInput line to print the id of the item it wanted to kill to the console to make sure I wasn't feeding it garbage IDs to kill. This is the "Found the following item entity id: 303" line you can see in the log file above.

If I comment out the AcceptEntityInput line, it stops segfaulting the server, and I also get the complete list of item entity IDs printed in the server console when it boots:

Set motd from file 'cfg/motd.txt'
Set motd_text from file 'cfg/motd_text_default.txt'.  ('cfg/motd_text.txt' was not found.)
SV_ActivateServer: setting tickrate to 66.7
Found the following item entity id: 303
Found the following item entity id: 148
Found the following item entity id: 151
Found the following item entity id: 152
Found the following item entity id: 309
Found the following item entity id: 145
Found the following item entity id: 153
Found the following item entity id: 278
Found the following item entity id: 279
Found the following item entity id: 302
Writing cfg/banned_user.cfg.
Writing cfg/banned_ip.cfg.
Unknown command "sm_reserve_type"
Unknown command "sm_reserved_slots"
Unknown command "sm_hide_slots"
Server is hibernating
Connection to Steam servers successful.
   Public IP to Steam is [redacted].
Assigned anonymous gameserver Steam ID [A:1:2242754591:31819].
VAC secure mode

I'm guessing based on this behaviour coinciding with the 20th anniversary update that it's something to do with SourceMod's HL2:DM compatibility as it worked fine in the prior build (now called the "steam_legacy" beta in Steam)

Logs

I have attached a copy of the dump file that was referenced in the server console log extract above.

Please let me know if you require any additional logs, versions, etc.

crash_20241118173638_14.dmp

caxanga334 commented 1 hour ago

Did you disable sourcemod automatic gamedata updater or is using gamedata override for hl2dm?

I tested the posted code on my Windows Dedicated Server and it did not crash.

I also confirmed AcceptEntityInput is working correctly on Linux with another plugin.

Pricetx commented 1 hour ago

Did you disable sourcemod automatic gamedata updater or is using gamedata override for hl2dm?

I tested the posted code on my Windows Dedicated Server and it did not crash.

I also confirmed AcceptEntityInput is working correctly on Linux with another plugin.

Hi, Thank you for getting back to me so quickly.

I disabled automatic gamedata updating. I then completely cleared out the gamedata folder and copied across fresh contents from the sourcemod snapshot download. This fixed the issue.

I have since enabled gamedata updating again and restarted the server and all seems fine.

I can only assume there was some data left behind from previous SourceMod builds in the gamedata folder that was conflicting and causing the segfaults. I wasn't aware that was a possibility so didn't test it!

This looks to be user error, so I am resolving.