PDA

View Full Version : CoD4 libcod Segmentation fault



Loveboy
19th March 2020, 12:29
Hello everyone,
I recently started to mod on CoD4, the first idea was to make libcod work on my server.
I downloaded libcod from kung (GitHub) and followed the procedures for compiling the libcod4_1_7.so file.

This is the output of every command I enter:

./doit.sh tar


##### TAR LIBCOD #####
libcod.tar created: 0


./doit.sh base


##### COMPILE GSC_ASTAR.CPP #####
##### COMPILE GSC_MYSQL.CPP #####
##### COMPILE SERVER.C #####
##### COMPILE GSC_MEMORY.CPP #####
##### COMPILE CRACKING.CPP #####
##### COMPILE GSC_MATH.CPP #####
##### COMPILE JAVA_EMBED.C #####
##### WARNING: Skipped java_embed.c because /root/helper/openjdk8 does not exist #####


./doit.sh cod4_1_7


##### COMPILE cod4_1_7 LIBCOD.CPP #####
In file included from gsc.hpp:48:0,
from libcod.cpp:10:
functions.hpp:33:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^~~~~~~
functions.hpp:142:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^~~~~~~
functions.hpp:154:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^~~~~~~
functions.hpp:167:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^~~~~~~
functions.hpp:178:3: warning: #warning static int rconPasswordAddress = NULL; [-Wcpp]
#warning static int rconPasswordAddress = NULL;
^~~~~~~
functions.hpp:189:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^~~~~~~
functions.hpp:200:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^~~~~~~
functions.hpp:238:3: warning: #warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL; [-Wcpp]
#warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL;
^~~~~~~
functions.hpp:250:3: warning: #warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL; [-Wcpp]
#warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL;
^~~~~~~
functions.hpp:262:3: warning: #warning SV_FlushRedirect_t SV_FlushRedirect = NULL; [-Wcpp]
#warning SV_FlushRedirect_t SV_FlushRedirect = NULL;
^~~~~~~
functions.hpp:274:3: warning: #warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL; [-Wcpp]
#warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL;
^~~~~~~
functions.hpp:286:3: warning: #warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL; [-Wcpp]
#warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL;
^~~~~~~
functions.hpp:298:3: warning: #warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL; [-Wcpp]
#warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL;
^~~~~~~
functions.hpp:310:3: warning: #warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL; [-Wcpp]
#warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL;
^~~~~~~
functions.hpp:328:3: warning: #warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL; [-Wcpp]
#warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL;
^~~~~~~
functions.hpp:340:3: warning: #warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL; [-Wcpp]
#warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL;
^~~~~~~
functions.hpp:352:3: warning: #warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL; [-Wcpp]
#warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL;
^~~~~~~
libcod.cpp:665:4: warning: #warning fire_grenade &sig2 = NULL; [-Wcpp]
#warning fire_grenade &sig2 = NULL;
^~~~~~~
libcod.cpp:1851:10: warning: #warning gamestate_info got no working addresses [-Wcpp]
#warning gamestate_info got no working addresses
^~~~~~~
libcod.cpp:1921:10: warning: #warning getAddressType() got no working addresses [-Wcpp]
#warning getAddressType() got no working addresses
^~~~~~~
libcod.cpp:1952:10: warning: #warning set_bot_pings() got no working addresses [-Wcpp]
#warning set_bot_pings() got no working addresses
^~~~~~~
libcod.cpp:1987:10: warning: #warning play_movement() got no working addresses [-Wcpp]
#warning play_movement() got no working addresses
^~~~~~~
libcod.cpp:2708:5: warning: #warning int *addressToPickUpItemPointer = NULL; [-Wcpp]
#warning int *addressToPickUpItemPointer = NULL;
^~~~~~~
libcod.cpp:2734:5: warning: #warning int *addressToDownloadPointer = NULL; [-Wcpp]
#warning int *addressToDownloadPointer = NULL;
^~~~~~~
libcod.cpp:2751:14: warning: #warning int *addressToUserInfoPointer = NULL; [-Wcpp]
#warning int *addressToUserInfoPointer = NULL;
^~~~~~~
libcod.cpp: In function ‘int fire_grenade(int, int, int, int, int)’:
libcod.cpp:666:19: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
*(int *)&sig2 = NULL;
^~~~
##### COMPILE cod4_1_7 GSC.CPP #####
In file included from gsc.hpp:48:0,
from gsc.cpp:1:
functions.hpp:33:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^~~~~~~
functions.hpp:142:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^~~~~~~
functions.hpp:154:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^~~~~~~
functions.hpp:167:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^~~~~~~
functions.hpp:178:3: warning: #warning static int rconPasswordAddress = NULL; [-Wcpp]
#warning static int rconPasswordAddress = NULL;
^~~~~~~
functions.hpp:189:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^~~~~~~
functions.hpp:200:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^~~~~~~
functions.hpp:238:3: warning: #warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL; [-Wcpp]
#warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL;
^~~~~~~
functions.hpp:250:3: warning: #warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL; [-Wcpp]
#warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL;
^~~~~~~
functions.hpp:262:3: warning: #warning SV_FlushRedirect_t SV_FlushRedirect = NULL; [-Wcpp]
#warning SV_FlushRedirect_t SV_FlushRedirect = NULL;
^~~~~~~
functions.hpp:274:3: warning: #warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL; [-Wcpp]
#warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL;
^~~~~~~
functions.hpp:286:3: warning: #warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL; [-Wcpp]
#warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL;
^~~~~~~
functions.hpp:298:3: warning: #warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL; [-Wcpp]
#warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL;
^~~~~~~
functions.hpp:310:3: warning: #warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL; [-Wcpp]
#warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL;
^~~~~~~
functions.hpp:328:3: warning: #warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL; [-Wcpp]
#warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL;
^~~~~~~
functions.hpp:340:3: warning: #warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL; [-Wcpp]
#warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL;
^~~~~~~
functions.hpp:352:3: warning: #warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL; [-Wcpp]
#warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL;
^~~~~~~
##### COMPILE cod4_1_7 GSC_PLAYER.CPP #####
In file included from gsc.hpp:48:0,
from gsc_player.hpp:14,
from gsc_player.cpp:1:
functions.hpp:33:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^~~~~~~
functions.hpp:142:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^~~~~~~
functions.hpp:154:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^~~~~~~
functions.hpp:167:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^~~~~~~
functions.hpp:178:3: warning: #warning static int rconPasswordAddress = NULL; [-Wcpp]
#warning static int rconPasswordAddress = NULL;
^~~~~~~
functions.hpp:189:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^~~~~~~
functions.hpp:200:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^~~~~~~
functions.hpp:238:3: warning: #warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL; [-Wcpp]
#warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL;
^~~~~~~
functions.hpp:250:3: warning: #warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL; [-Wcpp]
#warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL;
^~~~~~~
functions.hpp:262:3: warning: #warning SV_FlushRedirect_t SV_FlushRedirect = NULL; [-Wcpp]
#warning SV_FlushRedirect_t SV_FlushRedirect = NULL;
^~~~~~~
functions.hpp:274:3: warning: #warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL; [-Wcpp]
#warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL;
^~~~~~~
functions.hpp:286:3: warning: #warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL; [-Wcpp]
#warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL;
^~~~~~~
functions.hpp:298:3: warning: #warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL; [-Wcpp]
#warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL;
^~~~~~~
functions.hpp:310:3: warning: #warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL; [-Wcpp]
#warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL;
^~~~~~~
functions.hpp:328:3: warning: #warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL; [-Wcpp]
#warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL;
^~~~~~~
functions.hpp:340:3: warning: #warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL; [-Wcpp]
#warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL;
^~~~~~~
functions.hpp:352:3: warning: #warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL; [-Wcpp]
#warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL;
^~~~~~~
gsc_player.cpp:410:4: warning: #warning getSVSTime() got no working addresses [-Wcpp]
#warning getSVSTime() got no working addresses
^~~~~~~
gsc_player.cpp:424:4: warning: #warning gsc_player_getLastConnectTime() got no working addresses [-Wcpp]
#warning gsc_player_getLastConnectTime() got no working addresses
^~~~~~~
gsc_player.cpp:440:4: warning: #warning getLastPacketTime() got no working addresses [-Wcpp]
#warning getLastPacketTime() got no working addresses
^~~~~~~
gsc_player.cpp:465:4: warning: #warning gsc_player_addresstype() got no working addresses [-Wcpp]
#warning gsc_player_addresstype() got no working addresses
^~~~~~~
gsc_player.cpp:591:3: warning: #warning calc_player_speed_t calc_player_speed = NULL; [-Wcpp]
#warning calc_player_speed_t calc_player_speed = NULL;
^~~~~~~
gsc_player.cpp:603:3: warning: #warning calc_client_speed_t calc_client_speed = NULL; [-Wcpp]
#warning calc_client_speed_t calc_client_speed = NULL;
^~~~~~~
gsc_player.cpp:756:3: warning: #warning gsc_player_set_anim() got no working addresses for anim_offset [-Wcpp]
#warning gsc_player_set_anim() got no working addresses for anim_offset
^~~~~~~
gsc_player.cpp:922:4: warning: #warning gsc_kick_slot() got no working addresses for guid_offset [-Wcpp]
#warning gsc_kick_slot() got no working addresses for guid_offset
^~~~~~~
gsc_player.cpp:959:4: warning: #warning gsc_player_setguid() got no working addresses for guid_offset [-Wcpp]
#warning gsc_player_setguid() got no working addresses for guid_offset
^~~~~~~
##### COMPILE cod4_1_7 GSC_UTILS.CPP #####
In file included from gsc.hpp:48:0,
from gsc_utils.hpp:14,
from gsc_utils.cpp:1:
functions.hpp:33:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^~~~~~~
functions.hpp:142:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^~~~~~~
functions.hpp:154:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^~~~~~~
functions.hpp:167:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^~~~~~~
functions.hpp:178:3: warning: #warning static int rconPasswordAddress = NULL; [-Wcpp]
#warning static int rconPasswordAddress = NULL;
^~~~~~~
functions.hpp:189:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^~~~~~~
functions.hpp:200:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^~~~~~~
functions.hpp:238:3: warning: #warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL; [-Wcpp]
#warning static SV_ConnectionlessPacket_t SV_ConnectionlessPacket = NULL;
^~~~~~~
functions.hpp:250:3: warning: #warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL; [-Wcpp]
#warning NET_OutOfBandPrint_t NET_OutOfBandPrint = NULL;
^~~~~~~
functions.hpp:262:3: warning: #warning SV_FlushRedirect_t SV_FlushRedirect = NULL; [-Wcpp]
#warning SV_FlushRedirect_t SV_FlushRedirect = NULL;
^~~~~~~
functions.hpp:274:3: warning: #warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL; [-Wcpp]
#warning static SV_GameSendServerCommand_t SV_GameSendServerCommand = NULL;
^~~~~~~
functions.hpp:286:3: warning: #warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL; [-Wcpp]
#warning SV_StopDownload_f_t SV_StopDownload_f = (SV_StopDownload_f_t)NULL;
^~~~~~~
functions.hpp:298:3: warning: #warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL; [-Wcpp]
#warning SV_DropClient_t SV_DropClient = (SV_DropClient_t)NULL;
^~~~~~~
functions.hpp:310:3: warning: #warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL; [-Wcpp]
#warning static SV_WriteDownloadToClient_t SV_WriteDownloadToClient = (SV_WriteDownloadToClient_t)NULL;
^~~~~~~
functions.hpp:328:3: warning: #warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL; [-Wcpp]
#warning ClientUserinfoChanged_t changeClientUserinfo = (ClientUserinfoChanged_t)NULL;
^~~~~~~
functions.hpp:340:3: warning: #warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL; [-Wcpp]
#warning Info_SetValueForKey_t Info_SetValueForKey = (Info_SetValueForKey_t)NULL;
^~~~~~~
functions.hpp:352:3: warning: #warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL; [-Wcpp]
#warning Info_ValueForKey_t Info_ValueForKey = (Info_ValueForKey_t)NULL;
^~~~~~~
gsc_utils.cpp:934:4: warning: #warning findIndexWeapon_t findIndexWeapon = NULL; [-Wcpp]
#warning findIndexWeapon_t findIndexWeapon = NULL;
^~~~~~~
gsc_utils.cpp:1035:4: warning: #warning get_weapon_t get_weapon = NULL; [-Wcpp]
#warning get_weapon_t get_weapon = NULL;
^~~~~~~
##### LINK libcod4_1_7.so #####


./doit.sh wrapper


##### Unrecognized command line option wrapper #####



It created libcod4_1_7.so in bin folder. I copied it and placed it in my server folder.
Now running my server.sh with the content


LD_PRELOAD="./libcod4_1_7.so" ./cod4_lnxded-bin +set fs_game mods/test +set net_port 28960 +exec server.cfg +map_rotate

this error will be thrown:


./server.sh: line 1: 23845 Segmentation fault (core dumped) LD_PRELOAD="./libcod4_1_7.so" ./cod4_lnxded-bin +set fs_game mods/test +set net_port 28960 +exec server.cfg +map_rotate


I have seen some threads here where others were facing this problem too, but I coudn't find a solution for me.
I also installed mysql on my Ubuntu-Server,
have mysql.cfg (which also will be executed) with the content


set mysql_host "127.0.0.1";
set mysql_user "test";
set mysql_pass "test";
set mysql_db "test";
set mysql_port 3306

and I have this part in _callbacksetup.gsc in CodeCallback_StartGameType()


host = getdvar("mysql_host");
user = getdvar("mysql_user");
pass = getdvar("mysql_pass");
db = getdvar("mysql_db");
port = getdvarint("mysql_port");

if(host!="" && user != "" && pass != "" && db != "" && port != 0)
{
std\mysql::make_global_mysql(host, user, pass, db, port);
}


and have in the mod folder


std/io.gsc
std/mysql.gsc



Mysql is not that necessary for me right now, I just want to get libcod run on my CoD4 server.
I already tested some precompiled .so files, which of these only one worked and others gave me the same error (Segmentation fault).
The file which worked was http://killtube.org/downloads/libcod/2014_04_18/libcod4_1_7.so
The reason I don't want to use the precompiled version is because I want to modify the source code to
fix some features which in CoD2 worked but in CoD4 not (already found some solutions here).

maxdamage99
23rd March 2020, 07:08
Without connecting to MySQL, server is working fine?
Connection data (server, db, user, pass) faithful and really exist?

Stupid idea of course, but try to enter specific IP in the host or fix it to "localhost".
It is also worth looking at the allowed connections for the user ("%", "localhsot" etc): in phpmyadmin for example

voron00
23rd March 2020, 10:44
If i remember correctly, some offsets for cod4 in libcod are incorrect, at least i had to correct playercommand offset the last time i tried it.

Why not use cod4x? I think it does have a mysql plugin.

Loveboy
23rd March 2020, 14:03
MySQL connection works fine, I tried to use with and without

And now I use mysql plugin for cod4x. First I had some problem setting it up (because of poor instructions),
but now it finally works.

¯\_(ツ)_/¯