pawn-lang / YSI-Includes

Just the YSI include files, none of the extra stuff.
211 stars 105 forks source link

Server crash when hooking OnQueryError() from a_mysql #555

Open ghost opened 3 years ago

ghost commented 3 years ago

Issue description:

When hooking OnQueryError(), the server crashes.

MCVE

main.pwn

#include <a_samp>
#include <a_mysql>
#include <YSI_Coding\y_hooks>

main()
{
    new MySQL:conn = mysql_connect(HOST, USER, PASS, DB); //NOTE: Use your own details here.
    mysql_tquery(conn, "CELEKT * FORM Foo;", "Foo");
    mysql_close(conn);
}

forward Foo();
public Foo()
{
    print("Called::Foo()");
}

hook OnQueryError(errorid, const error[], const callback[], const query[], MySQL:handle)
{
    print("Called::HOOK:OnQueryError()");
}

Workaround/temporary(?) fix

Workspace Information

Logs

Crashlog ``` [log-core] fatal signal '11' (SIGSEGV) catched [debug] Server crashed while executing kgm.amx [debug] AMX backtrace: [debug] #0 0c5ed114 in @yH_OnQueryError@006 (errorid=1452, error[]=@000c6d28 "Cannot add or update a child row: a foreign key constraint fails (`kevin_kgm`.`l...", callback[]=@000c6cc0 "l_Log_System__CheckResult", query[]=@000c6b98 "INSERT INTO log_system (accid, type, content) VALUES (1001, 1, 'Panic!');", MySQL:handle=1) at kgm.pwn:194 [debug] #1 0001911c in public OnQueryError (1452, 814376, 814272, 813976, 1) at /home/kevin/git/kgm-core/dependencies/includes/YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:132 [debug] Native backtrace: [debug] #0 f7a01f7f in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () in plugins/crashdetect.so [debug] #1 f79fa81d in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7ContextE () in plugins/crashdetect.so [debug] #2 f79fae48 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7ContextE () in plugins/crashdetect.so [debug] #3 f79fc5dc in _ZN11CrashDetect7OnCrashERKN2os7ContextE () in plugins/crashdetect.so [debug] #4 f7a0179f in ?? () in plugins/crashdetect.so [debug] #5 f7f72570 in __kernel_rt_sigreturn () in linux-gate.so.1 [debug] #6 f7a038ca in amx_Exec () in plugins/crashdetect.so [debug] #7 f79fc0b4 in _ZN11CrashDetect11ProcessExecEPii () in plugins/crashdetect.so [debug] #8 f79ffe6f in ?? () in plugins/crashdetect.so [debug] #9 f64cfda1 in amx_Exec () in plugins/profiler.so [debug] #10 f64d24ff in _ZN15ProfilerHandler4ExecEPii () in plugins/profiler.so [debug] #11 f64d111b in ?? () in plugins/profiler.so [debug] #12 f7672e84 in ?? () in plugins/mysql.so [debug] #13 f7676249 in ?? () in plugins/mysql.so [debug] #14 f769d48b in ?? () in plugins/mysql.so [debug] #15 f768545b in ?? () in plugins/mysql.so [debug] #16 f7685229 in ?? () in plugins/mysql.so [debug] #17 f76863b4 in ?? () in plugins/mysql.so [debug] #18 f76ae887 in ProcessTick () in plugins/mysql.so [debug] #19 080d1ce2 in ?? () in ./samp03svr [debug] #20 080aef3a in ?? () in ./samp03svr [debug] #21 080aa13a in ?? () in ./samp03svr [debug] #22 f7a4ba0d in __libc_start_main () in /usr/lib32/libc.so.6 [debug] #23 0804b4e1 in ?? () in ./samp03svr [debug] Registers: [debug] EAX: 00000000 EBX: 00000004 ECX: 010c6bd7 EDX: 000003f2 [debug] ESI: 082df9a0 EDI: f3a11010 EBP: 01106b54 ESP: ff888280 [debug] EIP: f7a038ca EFLAGS: 00010202 [debug] Stack: [debug] ESP+00000000: 082df9a0 00000049 ff8882cc f4b5e2d4 [debug] ESP+00000020: f3a57c2c 01106b94 000c704c 00000000 [debug] ESP+00000040: f7a2a860 082df9a0 00000001 00000000 [debug] ESP+00000060: 0844c050 ff888354 ff888388 f79fc0b4 [debug] ESP+00000080: 00000083 f7f40e70 081a1990 00000001 [debug] ESP+000000a0: 082da974 00000001 1403e6f6 f7650390 [debug] ESP+000000c0: 082df9a0 00000001 00000000 00000000 [debug] ESP+000000e0: f7c1d738 f7b81c71 081a199c 85e11300 [debug] ESP+00000100: 00000000 f64eb578 ff8883c8 f79ffe6f [debug] ESP+00000120: 084849ac f64eb000 08480e80 f64cfda1 [debug] ESP+00000140: f64cfd79 f64eb000 ff888408 f64d24ff [debug] ESP+00000160: ff8884a4 082e1c5c ff888418 08480ea4 [debug] ESP+00000180: 08480750 f64eb578 ff888438 f64d111b [debug] ESP+000001a0: 082df9a0 ff8884a4 00000000 f796848c [debug] ESP+000001c0: 082df9a0 00000000 00000083 f767690b [debug] ESP+000001e0: 082df9a0 00000000 00000083 f7677454 [debug] ESP+00000200: 000c6b98 00000000 00000000 08488624 [debug] ESP+00000220: 08489980 000c6d28 082e1c5c 00000000 [debug] ESP+00000240: 00000000 f7725be6 00000063 00000000 [debug] ESP+00000260: 00000000 75516e4f 45797265 726f7272 [debug] ESP+00000280: ff888520 00000668 ff888588 080dcdc9 [debug] ESP+000002a0: 203e213c 6d206f4e 2065646f 6c207369 [debug] ESP+000002c0: 6e756620 6f697463 696c616e 69207974 [debug] ESP+000002e0: f3b1c034 ff88857c ff888580 f79f304f [debug] ESP+00000300: f7a2a000 ff888614 f7a2a860 f79f9f94 [debug] ESP+00000320: 00044104 00000000 f79f9f6b f7a2a000 [debug] ESP+00000340: ff888614 0000004e ff88875c f4b5e748 [debug] ESP+00000360: 00000000 00000001 00000000 ff888614 [debug] ESP+00000380: 082df9a0 00000000 01106b7c 00044104 [debug] ESP+000003a0: 00044104 0000004e f79e4700 ff88869c [debug] ESP+000003c0: 082d8320 00000001 082d8320 28e06b6a [debug] ESP+000003e0: ff888698 f7f72dad 98bf516b 000045f3 [debug] Loaded modules: [debug] 00000000 - 00187dc3 samp03svr [debug] f7f72000 - f7f73164 linux-gate.so.1 [debug] f7f44000 - f7f47140 /usr/lib32/libdl.so.2 [debug] f7f22000 - f7f410dd /usr/lib32/libpthread.so.0 [debug] f7d11000 - f7f2f0aa /usr/lib32/libstdc++.so.6 [debug] f7c44000 - f7d0e9dc /usr/lib32/libm.so.6 [debug] f7c26000 - f7c419b8 /usr/lib32/libgcc_s.so.1 [debug] f7a2d000 - f7c2b108 /usr/lib32/libc.so.6 [debug] f7f74000 - f7fa4cb7 /lib/ld-linux.so.2 [debug] f79e2000 - f7a2a3d4 plugins/crashdetect.so [debug] f7f66000 - f7f6b892 plugins/filemanager.so [debug] f7651000 - f79e6eb2 plugins/mysql.so [debug] f762d000 - f7650d32 /home/kevin/git/kgm-core/plugins/../log-core.so [debug] f7f5b000 - f7f63803 /usr/lib32/librt.so.1 [debug] f64ec000 - f64fd474 /usr/lib32/libnss_files.so.2 [debug] f64bf000 - f64ead70 plugins/profiler.so [debug] f661a000 - f66299b4 plugins/sscanf.so [debug] f644a000 - f64bf838 plugins/samp_bcrypt.so ```
ghost commented 3 years ago

Updated. Appearantly I overlooked something and it only happens when OnQueryError() is hooked just once. So not really an issue. If one is not going to hook it, might as well just use the regular public function. -- Although hooking is still faster than the regular callbacks if I remember that correctly.

Anyway, keeping this open because it shouldn't crash anyway.