Segmentation Fault on v1.11.0 (linux server) using rehlds/metamod-r/agmodx
On a linux server (ubuntu 24.04) running on rehlds, metamod-r and agmodx, server crashes as soon as a player spawns and moves and/or shoots.
this issue doesn't happens with the same rehlds, metamod-r but without agmodx. also this issue doesn't happens on the previous bugfixedhl build.
Offsets might have changed in 1.11.0. They should now match HL25.
AG Mod X adds custom offsets. Try removing amxmodx/data/gamedata/common.games/custom from the server.
Crash was caused by a modified/corrupted weapon vtable. Try removing everything related to Ham Sandwich module from AG Mod X for testing
@rtxA
I'm not sure to understand, AG Mod X comes with my fork of BugfixedHL for the server side (maybe I should point that somewhere) for several reasons:
- It has custom features or bugfixes which I couldn't add from the AMXX side without doing some nasty hacks.
- It's compiled with older GCC in Linux for better compatibility.
So maybe reporting this issue here doesn't make sense, unless you're switching to the one from tmp64 which I don't recommend. I mean, only because something can fail unexpectly, they're not so different, there are some things missing like the fix to respawn with High FPS (the implementation is different and it's missing a CVar to manage how fast you can spawn, normally I set this to 0.95 for players with 125fps). Still, I have seen servers with AG Mod X working with tmp64 fork. Now, tmp64 has been updated to support new HL25, that's unfortunate for AG Mod X, because this change gameplay behaviour, unless there's a way to opt-out.
Other things to point out:
- AMX Mod X hasn't been updated to support latest signatures from HL25. Even if they do, would they work on BHL?
- Metamod-R could be conflicting on this? Try to use older versions to see if this doesn't happen.
Since AG Mod X to function properly obviously needs custom BugfixedHL and @rtxa too busy to add HL25 support to his fork, I suggest dividing the work:
• @rtxa briefly describes which things exactly are needed to be changed or added;
• @tmp64 using that info updates his fork to add support for AG Mod X;
• I try my best to make custom gamedata files;
• me and @headshoter carefully test new gamedll versions.
Profit 👍
What do you think, guys?
@Safety1st I have no issue testing builds or files on my servers. but I really dont want to be taking time from you and or @tmp64 to make a third party plugin work, I was interested in having both things working together mainly due to the new features, such as fog which could be cool to try on some competitive matches. As for that I was thinking on just using the code from the previous build and add the fog entity to it. Also was thinking on adding rain and snow entities to a new fork. RtxA Mentioned a few changes that needs to be made and I think some of them can be made to be adjusted via cvar. respawn time for example, and the "E doesnt instantly stops the player anymore" could be enabled/disabled with another cvar. seems to be neccesary as many competitive players are used to stop with the use button.
To resume what just been said, I would be glad to test and help into making both things work together as long as I dont take too much time from any of you.
I really dont want to be taking time from you
That's not a problem since I also run AGMX server. And interested in finding info for gamedata files.
to make a third party plugin work
There are a lot limitations for AMXX plugins as compared with dlls. So I believe we have a very case when it is right to add support for 3rd party plugin. I assume it only requires a few changes in BHL.
I'm reviewing the changes I made in my fork and what BHL from tmp64 requires to support AG Mod X is:
- Disable ladder crouch fix for being gameplay changing (fix made by Lev who didn't account for client prediction issues) https://github.com/rtxa/BugfixedHL/commit/c914701c7aaae3ce356d321b0dd11469cc352bb9
- Add
mp_respawn_delay. By default is set to 0.95 ( this is the fast you can spawn at 125fps with the old behaviour) https://github.com/rtxa/BugfixedHL/commit/d3cd5545c31fbea4f62daf48dfc4ef857b7271c2 -> https://github.com/rtxa/BugfixedHL/commit/3ea80f8a2cc9e22c77ca9b353fe2ec2893d9eccf. See https://github.com/rtxa/agmodx/issues/31#issuecomment-1453581300 for more info about the calculation.- Also note that implementation of tmp64 of
mp_respawn_fixis different: https://github.com/tmp64/BugfixedHL-Rebased/blob/master/src/game/server/player.cpp#L1413, what's the purpose of m_flRespawnTimer? Why it has been renamed? What implementation should be keep it? These are my changes on player.cpp https://github.com/rtxa/BugfixedHL/commits/master/dlls/player.cpp?author=rtxa
- Also note that implementation of tmp64 of
- Add
mp_wallgaussfrom AG: multiplier value to control how much damage does the gauss through walls https://github.com/rtxa/BugfixedHL/commit/07ee3910d06074fcf1e4b6b0c3085ce8c8b8e645 - Add
mp_rpg_fixfrom AG: Avoids self-damage on rocket launch when moving at high speeds or closer to a wall. https://github.com/rtxa/BugfixedHL/commit/5076586a9069a187bb2f89340568b0edb4c901f9 - Add
mp_blastradiusfrom AG: multiplier for radius of explosions https://github.com/rtxa/BugfixedHL/commit/3aafbeb26061b6488d9366d7bdbe84aca585ed31 - Fix bots not being send to welcome cam.
m_bInWelcomeCamdidn't reset when the player leaves the game. https://github.com/rtxa/BugfixedHL/commit/198bd787a38a5f3ed0ed715a4d7ae65a9f70b2f4#diff-23610fb94802bf7249a995f703d8590ea9d3d86632a98910b80cbbf7c22a2649R336 - Fix chat anti-flood muting the player indefinitely when the game is paused. It uses server uptime instead of game time because it doesn't run on server pause. Side-effects: server uptime is affected by Unix time problem on year 2038, so we need a better way to get time. https://github.com/rtxa/BugfixedHL/commit/1a1f75ba6ac369958becca8d0f00caddba512f30
- Increase delay for leaving welcome cam to 0.5 to give plugins more time to send to spec. AMXX's
set_task()only allows a minimum value of 0.1. https://github.com/rtxa/BugfixedHL/commit/198bd787a38a5f3ed0ed715a4d7ae65a9f70b2f4 -> https://github.com/rtxa/BugfixedHL/commit/9bebd59859e95f2d134b153e7e87f5b6b64a0b3f Why do we need this? See https://github.com/rtxa/agmodx/issues/47 - Allow to disable cooldown for sending
spectatorto players. This allows plugins to send to spec players without worrying about the command being blocked by settingspectator_cmd_delayto0. Note: gamedata wasn't available for BHL when I made this. Now we can accessm_flNextSpectatorCommand, but it's useful if we don't trust on gamedata being updated regularly. https://github.com/rtxa/BugfixedHL/commit/b7c1e5088a1b9ce2af95151a3cd70ba8f66d5066
I didn't take into account changes made by HL25 anniversary (that's requires a more extensive review to keep the behaviour the same for HL/AG pro players) or the GCC older version compability.
Offtopic: about limitation on AMXX plugins as compared with dlls, this can be fixed if we made an API inside BugfixedHL similar to what ReGameDLL does, allowing us to hook functions which would require Orpheu otherwise (Not supported in ReHLDS), not a good thing to look for signatures. This could improve a lot the modding for plugins that changes gameplay a lot (like Zombie mods, use of Weapon Mod, etc.) and make everyone benefit of BHL bugfixes and features. Anyway, some of the changes I made benefits 3rd party plugins too.
I'm having a related issue that is caused by the changes introduced in BHL-Server version 1.11.0, which also affected the issue described in this discussion. When I hook the Ham_Weapon_SecondaryAttack event using the Ham Sandwich module in AMX Mod X, the event incorrectly triggers during the primary attack instead of the secondary attack. This behavior is likely due to a mismatch or incorrect offset introduced in the updated version of BHL-Server (targeted for HL25), as noted in this issue comment.
Observations
- Reverting
dlls/hl.soto a previous BHL-Server version 1.10.4 restores the expected behavior, whereHam_Weapon_SecondaryAttackhooks correctly to the secondary attack. - This issue consistently appears in BHL-Server version 1.11.0 and later.
Steps to Reproduce
- Installed HLDS (steam_legacy) from SteamCMD.
- Installed ReHLDS and BHL-Server from the artifacts generated by GitHub Actions on the master branch.
- Installed Metamod and AMX MOD X.
- Hooked the
Ham_Weapon_SecondaryAttackevent using the AMX Mod X Ham Sandwich module. - Observed that the event incorrectly triggers on the primary attack instead of the secondary attack.
Suspected Cause
The issue seems to be related to changes introduced in BHL-Server version 1.11.0, which altered the layout of virtual function tables (vtable) in the hl.so binary. While the Ham Sandwich module for AMX Mod X hooks into virtual functions of game entities independently, these hooks depend on the vtable offsets being correctly aligned to function as intended.
When attempting to hook a specific event (e.g., Ham_Weapon_SecondaryAttack), I found that the vtable offsets were misaligned. The addition of CBaseEntity::MyTogglePointer to the CBasePlayerWeapon class's vtable in version 1.11.0 has resulted many functions, including CBasePlayerWeapon::PrimaryAttack and CBasePlayerWeapon::SecondaryAttack, being shifted down by one position. As a result, the hook for Ham_Weapon_SecondaryAttack inadvertently triggers the function associated with Ham_Weapon_PrimaryAttack.
Since the Ham Sandwich module relies on a predefined list of hooks (e.g., Ham_Spawn, Ham_TakeDamage, Ham_Killed, etc.), any changes in the vtable offsets due to updates in hl.so can lead to misaligned function mappings. This misalignment directly impacts the functionality of event handling within AMX Mod X, causing the hooks to behave unpredictably after updating to BHL-Server version 1.11.0 or later.
Environment Details
The issue was tested on a fresh installation with the following configuration:
- OS: Ubuntu 24.04 LTS x86_64
- HLDS (steam_legacy): 19:52:19 Aug 3 2020 (build 8684)
- ReHLDS: 3.14.0.839-dev (build 3842 - commit b29740c)
- BHL-Server: 1.13.0-dev
- Metamod-p/r: v1.21p38/r-1.3.0.149
- AMX Mod X: 1.10.0.5467
Errors Encountered During Setup
These errors seem to be directly related with BHL-Server (hl.so), they occurred during setup:
-
Error 1:
LoadLibrary failed on /home/user/rehlds/./valve/dlls/hl.so: ./libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/user/rehlds/./valve/dlls/hl.so) Host_Error: Couldn't get DLL API from /home/user/rehlds/./valve/dlls/hl.so! FATAL ERROR (shutting down): Host_Error: Couldn't get DLL API from /home/user/rehlds/./valve/dlls/hl.so!To resolve this, I removed
libstdc++.so.6from the ReHLDS directory, but this led to another error. -
Error 2:
Auto-restarting the server on crash ./hlds_linux: ./libgcc_s.so.1: version `GCC_7.0.0' not found (required by /lib/i386-linux-gnu/libstdc++.so.6)After removing
libgcc_s.so.1from the ReHLDS directory, the server started successfully.
@rtxa @0Ky @Safety1st Offset-related crashes should now be fixed in #262
@rtxa
m_flRespawnTimer was added in HL25 to fix the standing corpse bug.
- HL25: Respawn time is defined by the animation length. But if animation is longer than 4 seconds, respawn is allowed anyway.
-
BHL: Respawn time is a fixed (and hardcoded) value.
-
mp_respawn_fix == 0: 4 seconds -
mp_respawn_fix == 1(default): 1.5 seconds
-
Current BHL implementation has a bug where if mp_respawn_fix is 0, behavior is different from vanilla.
I don't think mp_respawn_fix is necessary at this point. I can add mp_respawn_delay, which sets MINIMUM time before a player can respawn. But the player will have to wait for the animation to end any way.
If by current BHL implementation you mean the bugfix that Lev did, then yes, the behaviour is different. It's hardcoded like you said (1.5 seconds), but in my implementation, I have set a fixed cooldown of 0.95 seconds based on how long it takes to respawn when playing the game at 125fps in Vanilla HL. Do not wait for animation to end, otherwise players would be able to respawn sooner and it would be unfair for everyone (If I have understand you correctly).
PD: I'm fine with removing mp_respawn_fix if you want to leave the fix always enabled. PD2: mp_respawn_delay is a must in case players prefer another cooldown.
My idea is to wait until animation ends AND until mp_respawn_delay seconds pass. Assuming animation is fast, mp_respawn_delay will define how long to wait until respawn.
The behavior is now:
-
mp_respawn_fix == 0:- Wait for animation to end.
- This is HL25 behavior.
-
mp_respawn_delayis ignored
-
mp_respawn_fix == 1:- Wait until
mp_respawn_delayseconds pass, animation is ignored. - This is BHL behavior.
- Wait until
I decided to keep mp_respawn_fix cvar and leave it enabled by default. It fixes a different bug: death animation times are not consistent. With it enabled, players will always respawn after mp_respawn_delay seconds.
Yeah, I think is fine, mp_respawn_fix should fix:
- Standing corpses bugs (animations not ending correctly due to player spawning faster than the animation). In that case, just setting the animation sequence to the last frame should fix it.
- Allow to respawn after X seconds with mp_respawn_delay with 0.95 as default value. This makes respawn FPS independent and fair for everyone.
By the way, are you looking into the other issues? Like the chat anti-flood not working on pause and muting you? Or the remove of the ladder crouch fix? Thanks for taking a look to this.
- Disable ladder crouch fix - I'll add a cvar but I will leave it enabled by default
- Add mp_respawn_delay - #269 but I left it at 1.5 sec
- Add mp_wallgauss - #265
- Add mp_rpg_fix - #265
- Add mp_blastradius - #265
- Fix bots not being send to welcome cam - was already fixed
- Fix chat anti-flood muting the player indefinitely when the game is paused - #266
- Increase delay for leaving welcome cam to 0.5 to give plugins more time to send to spec - #268
- Allow to disable cooldown for sending spectator to players - since offsets are now available, you can use
m_flNextSpectatorCommand. In case I ever forget to update them, I released the tool: amxx-offset-generator
Well, I don't like the default value for the respawn delay, I remember getting feedback from the players about being too slow when set to 1.5 on competitive matches. LLHL and agmod-updated (currently being used in the team world cup) uses a default of 0.75. Here are my calculations: https://github.com/rtxa/agmodx/issues/31#issuecomment-1453581300
About the ladder crouch fix, I don't think it should be enabled by default, as I said before, it causes client prediction issues on players with vanilla HL or clients not using BHL and it's gameplay changing.
Good for implementing the rest of it!
Add mp_respawn_delay - https://github.com/tmp64/BugfixedHL-Rebased/pull/269 but I left it at 1.5 sec
I agree with @rtxa, the default value is too high, it's higher than the official Half-Life (post 25th-Anniversary update). I think it would be ideal to set it to 0.85 seconds, matching the average official respawn time at 100 fps for consistency.
Also, the current naming could be improved to better reflect what these cvars actually do. Right now, mp_respawn_fix is not clear without looking up what it fixes through the commit or reading this issue, which can be confusing. I would suggest more descriptive names:
mp_respawn_fix to mp_respawn_enforcedelay
mp_respawn_delay to mp_respawndelay_min
I'd like to suggest adding a new cvar mp_respawndelay_max with a default value of 6 to match the current hard-coded forced respawn delay. Although mp_forcerespawn is enabled by default to force players to respawn after death, players can currently circumvent it by holding a button (kill;+alt1) and remain dead indefinitely. This cvar would enforce a maximum respawn delay to prevent that behavior.
I believe the 5-second force respawn timer starts after the player becomes respawnable, which is after the death animation delay. That's why the actual respawn might be longer than 5 seconds and I think setting 6 as the default value is ideal.