Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

Player:StripWeapon() sometimes crashes servers on 32bit Linux #6007

Open fiercestwarrior opened 1 month ago

fiercestwarrior commented 1 month ago

Protocol version 24 Exe version 2023.06.28 (garrysmod) Exe build: 17:30:28 Jul 24 2024 (9391) (4000) GMod version 2024.08.09, branch: unknown Linux 32bit Dedicated Server

Details

We've been having crashes seemingly randomly on our Physgun server which the Physgun crash handler has attributed as an 'infinite loop' however I'm more inclined to believe it's a memory fault and/or physics issue on Linux. The lua stack traces we get in our crash logs are generally inconsistent but here's one of them.

Note: ClockworkStripWeapon() is an alias for StripWeapon()

/proc/1/fd/4(+0x2f4f9)[0xf797a4f9]
/proc/1/fd/4(+0x2f92b)[0xf797a92b]
/usr/lib32/libstdc++.so.6(+0xb26cd)[0xf7b966cd]
/lib/i386-linux-gnu/libpthread.so.0(+0x70b4)[0xf7e9e0b4]
/lib/i386-linux-gnu/libc.so.6(clone+0x66)[0xf7dae386]

Lua Stack:
[C][+0] [C] in ClockworkStripWeapon
[L][+1] gamemodes/clockwork/framework/sv_kernel.lua:1344 in method StripWeapon Line 1334 -> 1346
[L][+2] gamemodes/clockwork/framework/items/bases/sh_weapon_base.lua:244 in method OnPlayerUnequipped Line 155 -> 318
[L][+3] gamemodes/clockwork/framework/hooks/sv_nethooks.lua:391 in anonymous function Line 364 -> 397
[L][+4] gamemodes/clockwork/gamemode/external/netstream.lua:165 in local func Line 147 -> 177
[L][+5] lua/includes/extensions/net.lua:38 in anonymous function Line 23 -> 40
[C][+6] [C] in xpcall
[L][+7] [string "__phys_aa_caller.lua"]:7 in anonymous function Line 6 -> 8

 End of stack trace
This crash was caused by an infinite loop, this is most likely one of your addons. Read the stack dump above, and try removing the addons in the list. If you need more help, visit the physgun discord.

The mentioned code at +1

-- A function to strip a weapon from a player.
function playerMeta:StripWeapon(weaponClass)
    if (self:IsRagdolled()) then
        local ragdollWeapons = self:GetRagdollWeapons()

        for k, v in pairs(ragdollWeapons) do
            if (v.weaponData["class"] == weaponClass) then
                ragdollWeapons[k] = nil
            end
        end
    else
        self:ClockworkStripWeapon(weaponClass)
    end
end

A fix was attempted to remove the weapon prior but that didn't work.

    else

        local weaponObj = self:GetWeapon(weaponClass);

        if IsValid(weaponObj) then
            weaponObj:Remove();
        end

        self:ClockworkStripWeapon(weaponClass)
    end
end

So, we decided to look back on previous messages in discords as well as github issues that are possibly related to our issue.

4959 (This one has notable crash logs)

4960

4954

https://discord.com/channels/565105920414318602/567617926991970306/1110891340574765177 (Link to a message similar to #4959 in the gmod discord (otherwise just search 'Sometime when I strip my hand weapon the server crash?'))

This is complete assumption by me at this point but I think StripWeapon 'dropping' weapons (which I didn't even know happened because it's not documented on the wiki and I only found out through #5956) causes some physics related issues and thus crashes the server.

code_gs also said this in response to the discord message, incase if its anything of note image

Steps to reproduce

  1. Call StripWeapon() on a player
  2. Hope it doesn't crash (or do hope if you want to reproduce this random bullshit)
robotboy655 commented 1 month ago

The obvious question is, does it happen without your binary modules?