tmp64 / BugfixedHL-Rebased

Bugfixed and improved Half-Life
GNU General Public License v3.0
108 stars 22 forks source link

Vector ABI incompatibility #137

Closed andreiseverin closed 2 years ago

andreiseverin commented 2 years ago

Hello,

I tried to install the latest version with the latest version of REHLDS but the server is crashing when starting:

version Protocol version 48 Exe version 1.1.2.2/Stdio (valve) ReHLDS version: 3.11.0.776-dev Build date: 19:37:50 Apr 20 2022 (2930) Build from: https://github.com/dreamstalker/rehlds/commit/3dc9f8c

Crash log :

`container@pterodactyl~ Server marked as running... VAC secure mode is activated. /entrypoint.sh: line 36: 42 Segmentation fault (core dumped) ./hlds_run -console -game ${HLDS_GAME} -port ${SERVER_PORT} -sport ${VAC_PORT} +map ${SRCDS_MAP} +ip 0.0.0.0 -strictportbind -norestart +maxplayers 22 container@pterodactyl~ Server marked as offline...

[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ---------- [Pterodactyl Daemon]: Exit code: 139 [Pterodactyl Daemon]: Out of memory: false [Pterodactyl Daemon]: Updating process configuration files... [Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds... container@pterodactyl~ Server marked as starting... [Pterodactyl Daemon]: Pulling Docker container image, this could take a few minutes to complete... [Pterodactyl Daemon]: Finished pulling Docker container image`

Current BugfixedHL version: aghl.ru "aghl.ru" is "1.5.1+master.7e6b184"

tmp64 commented 2 years ago

I tested with ReHLDS 3.11.0.776, metamod-p 1.21p38 and BHL 1.7.2 on Arch Linux and it works without any issue.

You should update BHL to the latest version. If you're using metamod-p, try adding +localinfo mm_gamedll dlls/hl.so to the command line. It doesn't always detect the game dll correctly.

It the issue persists, add -dev +log on to the command line and post your Linux distribution version, full console log and the core dump (location depends on distribution).

andreiseverin commented 2 years ago

It seems I had an old metamod version installed and this could be the reason why it wasn't working. After I installed the metamod-p 1.21p38 the server didn't crash anymore. I tried to check the current version but the aghl.ru command doesn't return anything. So, I am not sure if the build it's installed correctly. Also the amx_modules doesn't show the bugfixedhl api amx_modules

Currently loaded modules:
name                    version     author               status     
FakeMeta                1.9.0.5294  AMX Mod X Dev Team   running    
Ham Sandwich            1.9.0.5294  AMX Mod X Dev Team   running    
Engine                  1.9.0.5294  AMX Mod X Dev Team   running    
Fun                     1.9.0.5294  AMX Mod X Dev Team   running    
GeoIP                   1.9.0.5294  AMX Mod X Dev Team   running    
5 modules

Neither do the meta list command

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src   load  unlod
 [ 1] JK_Botti         RUN   -    jk_botti_mm_i386  v1.43     ini   Start ANY  
 [ 2] AMX Mod X        RUN   -    amxmodx_mm_i386.  v1.9.0.5  ini   Start ANY  
 [ 3] Reunion          RUN   -    reunion_mm_i386.  v0.1.75   ini   Start Never
 [ 4] FakeMeta         RUN   -    fakemeta_amxx_i3  v1.9.0.5  pl2   ANY   ANY  
 [ 5] Ham Sandwich     RUN   -    hamsandwich_amxx  v1.9.0.5  pl2   ANY   ANY  
 [ 6] Engine           RUN   -    engine_amxx_i386  v1.9.0.5  pl2   ANY   ANY  
 [ 7] Fun              RUN   -    fun_amxx_i386.so  v1.9.0.5  pl2   ANY   ANY  
 [ 8] GeoIP            RUN   -    geoip_amxx_i386.  v1.9.0.5  pl2   
ANY   ANY  
8 plugins, 8 running

Should I hard-code it in the modules.ini file? What are the pros of using this API ?

LE: Apparently the build was not loaded. I checked multiple server commands and I also saw that the bhop was not working. So, I took your advice and added the +localinfo mm_gamedll dlls/hl.so line to the startup command and this time the server crashed as before. In consequence, I added the line -dev +log on too. Four log files were generated (attached here). L0509003.log L0509002.log L0509001.log L0509000.log

Please let me know if you need something else from me.

tmp64 commented 2 years ago

Should I hard-code it in the modules.ini file? What are the pros of using this API ?

It will be loaded automatically if a plugin requires it (I don't believe there are any public plugins that use it though). It provides a few BHL-specific functions like querying player's MOTD or color support. See the wiki for details.

this time the server crashed as before

I don't see anything critically wrong in the logs (only that the AMXX module failed to load, need to check if it still works). You need to check the core (crash) dump. See if there is a file named core in the server directory. If not, find out where your Linux distribution keeps its core dumps. Once you find it, please post it here along with the Linux distribution version.

andreiseverin commented 2 years ago

I don't see anything critically wrong in the logs (only that the AMXX module failed to load, need to check if it still works). You need to check the core (crash) dump. See if there is a file named core in the server directory. If not, find out where your Linux distribution keeps its core dumps. Once you find it, please post it here along with the Linux distribution version.

The host told me that the server is running on Ubuntu 18.04. There are 2 core files, one so and one of ~180MB. I put them both on an archive but I couldn't upload it directly here. Heres the link to it : https://mega.nz/file/ahIRiDzS#Jvj3tFIb3wFtGxHA5zW6rdZ2CNaqE_rH86sFFf8JFY0

tmp64 commented 2 years ago

Looks like the crash happens in jk_botti. Try disabling it

andreiseverin commented 2 years ago

Looks like the crash happens in jk_botti. Try disabling it

Yes, you were right. After disabling jk_botti it worked and no more crashes. I suppose there's an incompatibility with this plugin. Any way to solve it? Most of the servers are using jk_botti and we need them too on our server. On the 1.5.1 version they are working.

tmp64 commented 2 years ago

I'll look into what is causing the crash

tmp64 commented 2 years ago

Tested, doesn't crash. Try disabling all other metamod plugins

andreiseverin commented 2 years ago

Tested, doesn't crash. Try disabling all other metamod plugins

I only have these ones:

;linux addons/jk_botti/dlls/jk_botti_mm_i386.so
linux addons/amxmodx/dlls/amxmodx_mm_i386.so
linux addons/reunion/reunion_mm_i386.so
;linux addons/bunny/bunnyjump_mm_i386.so

I disabled the bunnyhop plugin due to the BHL feature already integrated so I only got the amxmodx and reunion besides the jk_botti.

If I disable the jk_botti, it works:

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src   load  unlod
 [ 1] AMX Mod X        RUN   -    amxmodx_mm_i386.  v1.9.0.5  ini   Start ANY  
 [ 2] Reunion          RUN   -    reunion_mm_i386.  v0.1.75   ini   Start Never
 [ 3] BugfixedAPI      RUN   -    bugfixedapi_amxx  v1.7.2+m  pl1   ANY   ANY  
 [ 4] FakeMeta         RUN   -    fakemeta_amxx_i3  v1.9.0.5  pl1   ANY   ANY  
 [ 5] Ham Sandwich     RUN   -    hamsandwich_amxx  v1.9.0.5  pl1   ANY   ANY  
 [ 6] Engine           RUN   -    engine_amxx_i386  v1.9.0.5  pl1   ANY   ANY  
 [ 7] Fun              RUN   -    fun_amxx_i386.so  v1.9.0.5  pl1   ANY   ANY  
 [ 8] GeoIP            RUN   -    geoip_amxx_i386.  v1.9.0.5  pl1   ANY   ANY  
8 plugins, 8 running
L 05/10/2022 - 17:07:54: [admin.amxx] Login: "|-RT-|teylo<1><STEAM_0:1:106843133><>" became an admin (account "STEAM_0:1:106843133") (access "abcdefghijklmnopqrstuv") (address "84.232.220.63")
aghl.ru
"aghl.ru" is "1.7.2+master.12ddc7c"
tmp64 commented 2 years ago

What if you only leave jk_botti enabled? You could also try updating it to the latest version

andreiseverin commented 2 years ago

What if you only leave jk_botti enabled? You could also try updating it to the latest version

I run deeper with the test even after disabling jk_botti. The server crashes the moment someone is dealing damage, one to another or to himself. Here are the logs: L0510016.log L0510015.log L0510027.log L0510026.log L0510025.log L0510024.log L0510023.log L0510022.log L0510021.log L0510020.log L0510019.log L0510018.log L0510017.log

This led me to think some amxmodx functions are responsible for the crashes. The next step was to disable completely amxmodx and surprise, it works.

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src   load  unlod
 [ 1] JK_Botti         RUN   -    jk_botti_mm_i386  v1.43     ini   Start ANY  
 [ 2] Reunion          RUN   -    reunion_mm_i386.  v0.1.75   ini   Start Never
2 plugins, 2 running
L 05/10/2022 - 17:32:55: "Subject_Delta<1><BOT><1>" killed "ScarleTron<3><BOT><3>" with "9mmAR"
aghl.ru
"aghl.ru" is "1.7.2+master.12ddc7c"

So, the problem can come from a plugin or a module. Which version of amxmodx is recommended with this build?

tmp64 commented 2 years ago

Whatever latest AMXX will work.

I think there's an AMXX plugin that uses an outdated hardcoded offset, or I made a mistake somewhere and broke binary compatibility. Try disabling plugins one-by-one to find the one that causes the crashes.

andreiseverin commented 2 years ago

Whatever latest AMXX will work.

I think there's an AMXX plugin that uses an outdated hardcoded offset, or I made a mistake somewhere and broke binary compatibility. Try disabling plugins one-by-one to find the one that causes the crashes.

I found the culprit for this one. It's the sev (Severian mod) plugin I use on the server (source attached) sev.zip Official link to the plugin: https://aghl.ru/forum/viewtopic.php?f=19&t=528

The offsets are hardcoded as you said:

const m_pPlayer                     = 28
const m_fInSpecialReload            = 34
const m_flNextPrimaryAttack         = 35
const m_flNextSecondaryAttack       = 36
const m_flTimeWeaponIdle            = 37
const m_iClip                       = 40
const m_pBeam                       = 176
const m_flNextAttack                = 148
const LINUX_OFFSET_WEAPONS          = 4
const LINUX_OFFSET_AMMO             = 5
const OFFSET_AMMO_HEGRENADE         = 319

I don't know the correct values of the offsets used inside the build. Maybe you'll have an idea of which is wrong. Normally the new amxmodx versions don't need the hardcode the offsets but this is an old source.

tmp64 commented 2 years ago

Some time in 2019 Valve added a new field into CBaseToggle (commit), which CBasePlayer inherits from.

This small change should fix it.

const m_flNextAttack = 152 // 148 + 4
andreiseverin commented 2 years ago

Some time in 2019 Valve added a new field into CBaseToggle (commit), which CBasePlayer inherits from.

This small change should fix it.

const m_flNextAttack = 152 // 148 + 4

Not yet. It still crashes. Maybe it's another offset too.

tmp64 commented 2 years ago

I found the problem. v1.6.0 replaced server's own Vector implementation with the one from Source SDK's mathlib. Original Vector is being passed to functions on the stack, while Source's is in registers. This broke compatibility with hooking modules like HamSandwich.

tmp64 commented 2 years ago

Fixed in 18a400c129f2836ea84a485fb93568e0ed581b27

andreiseverin commented 2 years ago

So this will be fixed in the next release?

tmp64 commented 2 years ago

Fixed and released in v1.8.0