Hello!
My name's Patrick, and I'm a mod developer for a game named Jedi Knight 2: Jedi Outcast.
The game is quite old (2002!) and I'm trying to mod the old version of it (1.02a), the jk2ded server linux binary.
The game engine loads my mod's .so file which I compiled using:
Code:
gcc -shared -static -g -fPIC g_syscalls.c common.c main.c -o out/jk2mpgamei386.so
So whilst launching the server for the first time, it loads the .so file using dlopen() without problems and the output is:
Code:
Loading dll file jk2mpgame.
Sys_LoadDll(/web/web11/jk2/base/jk2mpgamei386.so)...
Sys_LoadDll(jk2mpgame) found **vmMain** at 0xb2ed9413
Sys_LoadDll(jk2mpgame) succeeded!
[ NT's Fix ] GAME_INIT
and then it works correctly until I try to change the map the server is on currently.
When a map changes on the server, the .so file has to be unloaded.
After unloading with dlclose() without errors, when the new map is launched the engine tries to reload the .so into the memory with dlopen() but fails:
Code:
map_restart 0
Cvar_Set2: sv_serverid 78710500
==== ShutdownGame ====
ShutdownGame:
------------------------------------------------------------
[ NT's Fix ] GAME_SHUTDOWN
Loading dll file jk2mpgame.
Sys_LoadDll(/web/web11/jk2/base/jk2mpgamei386.so)...
Speicherzugriffsfehler
...crash with a segmentation fault error.
So I used gdb to find out why it does that, but all I got is:
Code:
(gdb) bt
#0 0x081099f0 in _dl_lookup_versioned_symbol (undef_name=0xb2efd81f "strlen", undef_map=0x838fee8, ref=0xbfdd56b8, symbol_scope=0x8390084, version=0x83901a0, type_class=0,
explicit=0) at do-lookup.h:52
#1 0x0812248b in _dl_relocate_object () at ../sysdeps/i386/dl-machine.h:348
#2 0x0810b987 in dl_open_worker (a=0xbfdd592c) at dl-open.c:294
#3 0x0810ae67 in _dl_catch_error (objname=0xbfdd5924, errstring=0xbfdd5928, operate=0x810b570 <dl_open_worker>, args=0xbfdd592c) at dl-error.c:152
#4 0x0810bac3 in _dl_open (file=0x8242ee0 "/web/web11/jk2/base/jk2mpgamei386.so", mode=-2147483646, caller=0x80b6778) at dl-open.c:407
#5 0x080dbeef in dlopen_doit (a=0xbfdd5a8c) at dlopen.c:39
#6 0x0810ae67 in _dl_catch_error (objname=0x829a3a0, errstring=0x829a3a4, operate=0x80dbed0 <dlopen_doit>, args=0xbfdd5a8c) at dl-error.c:152
#7 0x080dc132 in _dlerror_run (operate=0x80dbed0 <dlopen_doit>, args=0xbfdd5a8c) at dlerror.c:130
#8 0x080dbebd in __dlopen_check (file=0x8242ee0 "/web/web11/jk2/base/jk2mpgamei386.so", mode=2) at dlopen.c:53
#9 0x080b6778 in .B18.8 ()
#10 0x08242ee0 in fs_gamedir ()
(gdb)
Could you please tell me what could be the possible reason of why it crashes?
Kind regards
Patrick :-)