Zeex / sampgdk

Write SA-MP gamemodes in C/C++
http://zeex.github.io/sampgdk
Apache License 2.0
156 stars 83 forks source link

When using sampgdk plugins server always crashes with segmentation fault (CentOs 7) #192

Closed lleps closed 7 years ago

lleps commented 7 years ago

I can't run any sampgdk plugin on CentOs 7.

#include "sampgdk.h"

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
  return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
  return sampgdk::Load(ppData);
}

PLUGIN_EXPORT void PLUGIN_CALL Unload() {
  sampgdk::Unload();
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
  sampgdk::ProcessTick();
}

Building it with

g++ -m32 -DLINUX -DSAMPGDK_AMALGAMATION -ISDK -shared -o testgdk.so \
SDK/amxplugin.cpp sampgdk.c testgdk.cpp

When I run it on a clean linux server (without other plugins), server crashes with segmentation fault, immediately after the first filterscript loads. If I remove all filterscripts, it also crashes after any gamemode is loaded. I downloaded incognito streamer which also uses sampgdk, and it crashes. (even if i build it on the server) with the same problem.

I enabled debugging messages on sampgdk.c

static bool _sampgdk_log_enabled[] = {
  true, /* _SAMPGDK_LOG_DEBUG */
  true, /* _SAMPGDK_LOG_INFO */
  true,  /* _SAMPGDK_LOG_WARNING */
  true , /* _SAMPGDK_LOG_ERROR */
};

output:

$ ./samp03svr

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[20:26:35] 
[20:26:35] Server Plugins
[20:26:35] --------------
[20:26:35]  Loading plugin: testgdk.so
[20:26:35] [sampgdk:info] Version: 4.5.2
[20:26:35]   Loaded.
[20:26:35]  Loaded 1 plugins.

Started server on port: 7777, with maxplayers: 50 lanmode is OFF.

[20:26:35] 
[20:26:35] Filterscripts
[20:26:35] ---------------
[20:26:35]   Loading filterscript 'base.amx'...
[20:26:35] [sampgdk:debug] amx_Exec(0xa0442c0, 0xffcc26ac, 0), paramcount = 0, stk = 18284
Violación de segmento ( = seg fault in spanish)

I did the same on my ubuntu machine (here sampgdk works), output:

$ ./samp03svr
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[17:19:53] 
[17:19:53] Server Plugins
[17:19:53] --------------
[17:19:53]  Loading plugin: testgdk.so
[17:19:53] [sampgdk:info] Version: 4.5.2
[17:19:53]   Loaded.
[17:19:53]  Loaded 1 plugins.

Started server on port: 7777, with maxplayers: 50 lanmode is OFF.

[17:19:53] 
[17:19:53] Filterscripts
[17:19:53] ---------------
[17:19:53]   Loading filterscript 'base.amx'...
[17:19:53] [sampgdk:debug] amx_Exec(0x88622f0, 0xffd854bc, 0), paramcount = 0, stk = 18284
[17:19:53] [sampgdk:debug] amx_Exec returned 0
[17:19:53] [sampgdk:debug] amx_Register(0x88622f0, 0x8158ac0, -1)
[17:19:53] [sampgdk:debug] Registering native: numargs @ 0x809acb0
[17:19:53] [sampgdk:debug] Registering native: getarg @ 0x809acf0
(a bunch of "Registering native:" for each fs loaded)

Any advice to fix this? Thanks

lleps commented 7 years ago

Fixed! It was selinux, which is sort of security layer that seems to prevent memory hacking from plugins to the original samp server. You need to disable it. More info, here: https://www.tecmint.com/disable-selinux-temporarily-permanently-in-centos-rhel-fedora/