Zeex / subhook

Simple hooking library for C/C++ (x86 only, 32/64-bit, no dependencies)
BSD 2-Clause "Simplified" License
801 stars 124 forks source link

Subhook causing server to crash? #10

Closed AAvivB closed 9 years ago

AAvivB commented 9 years ago

Hey, I have been trying to fix this for days however I failed to. As a note: server has no network access so packages cannot be updated. Details: CentOS 6.6 x86_64 Server crashed while it tried to load YSF, kurta version(I also tried SKY, both are making the server crash). The server_log provides some info I have tried to debug and understand however I couldn't:

[19/07/2015 01:42:01] [debug] Server crashed due to an unknown error [19/07/2015 01:42:02] [debug] Native backtrace: [19/07/2015 01:42:02] [debug] #0 0043950b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so [19/07/2015 01:42:02] [debug] #1 0043220f in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so [19/07/2015 01:42:02] [debug] #2 004333fc in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so [19/07/2015 01:42:02] [debug] #3 00433866 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so [19/07/2015 01:42:02] [debug] #4 0043915c in ?? () from plugins/crashdetect.so [19/07/2015 01:42:02] [debug] #5 00d22410 in ?? () [19/07/2015 01:42:02] [debug] #6 004a2a85 in subhook_install () from plugins/YSF.so [19/07/2015 01:42:02] [debug] #7 004743d1 in _Z15InstallPreHooksv () from plugins/YSF.so [19/07/2015 01:42:02] [debug] #8 00488bf7 in Load () from plugins/YSF.so [19/07/2015 01:42:02] [debug] #9 080d2742 in ?? () from ./samp03svr [19/07/2015 01:42:02] [debug] #10 080d2afa in ?? () from ./samp03svr [19/07/2015 01:42:02] [debug] #11 080aa0d0 in ?? () from ./samp03svr [19/07/2015 01:42:02] [debug] #12 0029bd36 in __libc_start_main () from /lib/libc.so.6 [19/07/2015 01:42:02] [debug] #13 0804b4e1 in ?? () from ./samp03svr

Some extra info: as I tried to understand stuff a little bit by myself, I figured out the plugin crashes after this line: Namecheck_hook.Install((void )CAddress::FUNC_ContainsInvalidChars, (void )HOOK_ContainsInvalidChars); SA-MP server is 0.3.7 R2, plugin is the lastest one by kurta(R14 I believe). Thank you for your help!

AAvivB commented 9 years ago

Short update: I have tried compiling the plugin with SubHook v0.1 and the server did not crash on startup, however it did crash as the first filterscript was trying to load. When I removed the filterscripts, it crashed as the gamemode was trying to load. Might be releated to this(?) https://github.com/Zeex/subhook/issues/6

Zeex commented 9 years ago

Did you check both function addresses passed to Subhook::Install() by YSF? They could be just NULL, in which case it would be a bug in YSF itself.

Also you might want to debug this in gdb, I believe CentOS has it installed by default. If you compile YSF with debug info (the -g or -ggdb3 switch in gcc) you'll be able to see the values of variables and so on, which could help you figure out why it's crashing.

AAvivB commented 9 years ago

This is not a YSF bug, @Zeex as I tried running the same built plugin on another linux server, and it worked perfectly fine. It also works on Windows.

I'm gonna see what results I will get with the debugger and I will post them here later on.

Zeex commented 9 years ago

Do you have SELinux enabled?

AAvivB commented 9 years ago

Confirmed. Setting SELinux to permissive fixed the issue. However, seems like there is a new issue now - I will open a new issue soon.