Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault on v1.11.0 (linux server) using rehlds/metamod-r/agmodx #249

Open
headshoter opened this issue Oct 1, 2024 · 9 comments
Labels
crash Crash report server Server-side related

Comments

@headshoter
Copy link

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.

core.tar.gz

@tmp64 tmp64 added server Server-side related crash Crash report labels Oct 1, 2024
@tmp64
Copy link
Owner

tmp64 commented Oct 1, 2024

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.

@tmp64
Copy link
Owner

tmp64 commented Oct 1, 2024

Crash was caused by a modified/corrupted weapon vtable. Try removing everything related to Ham Sandwich module from AG Mod X for testing

@headshoter
Copy link
Author

@rtxa

@rtxa
Copy link

rtxa commented Oct 1, 2024

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.

@Safety1st
Copy link

Safety1st commented Oct 2, 2024

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?

@headshoter
Copy link
Author

@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.

@Safety1st
Copy link

Safety1st commented Oct 2, 2024

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.

@rtxa
Copy link

rtxa commented Oct 2, 2024

I'm reviewing the changes I made in my fork and what BHL from tmp64 requires to support AG Mod X is:

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.

@0Ky
Copy link

0Ky commented Oct 19, 2024

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.so to a previous BHL-Server version 1.10.4 restores the expected behavior, where Ham_Weapon_SecondaryAttack hooks correctly to the secondary attack.
  • This issue consistently appears in BHL-Server version 1.11.0 and later.

Steps to Reproduce

  1. Installed HLDS (steam_legacy) from SteamCMD.
  2. Installed ReHLDS and BHL-Server from the artifacts generated by GitHub Actions on the master branch.
  3. Installed Metamod and AMX MOD X.
  4. Hooked the Ham_Weapon_SecondaryAttack event using the AMX Mod X Ham Sandwich module.
  5. 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:

  1. 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.6 from the ReHLDS directory, but this led to another error.

  2. 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.1 from the ReHLDS directory, the server started successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Crash report server Server-side related
Projects
None yet
Development

No branches or pull requests

5 participants