pawn-lang / YSI-Includes

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

[5.x] Crashes/doesn't do anything when trying to call an inline from OnScriptInit #302

Open AGraber opened 6 years ago

AGraber commented 6 years ago

However, it doesn't crash when using OnGameModeInit. Is this expected? I don't know if I should be using OnScriptInit after all.

public OnScriptInit()
{
    [...]
    print("Conexión MySQL exitósa!");

    inline Test()
    {
        printf("se ejecuto inline test");
    }
    printf("se ejecuta el MySQL_TQueryInline ahora");
    MySQL_TQueryInline(Database, using inline Test, "SELECT Name FROM cuentas WHERE ID = 1");
    return 1;
}
[14:10:35]  ======================================= 
[14:10:35]  |                                     | 
[14:10:35]  |        YSI version 4.00.0001        | 
[14:10:35]  |        By Alex "Y_Less" Cole        | 
[14:10:35]  |                                     | 
[14:10:35]  ======================================= 
[14:10:35]  
[14:10:35] Conexión MySQL exitósa!
[14:10:35] se ejecuta el MySQL_TQueryInline ahora
[14:10:35] Number of vehicle models: 0
[14:10:36] [debug] Server crashed while executing OpenFZ.amx
[14:10:36] [debug] AMX backtrace:
[14:10:36] [debug] #0 native format () from samp-server.exe
[14:10:36] [debug] #1 00036414 in public Indirect_FromCallback (F@_@:cb=222152, bool:release=true) at E:\Programacion\test\gamemodes\test.pwn:1032
[14:10:36] [debug] Native backtrace:
[14:10:36] [debug] #0 00403334 in ?? () from samp-server.exe
[14:10:36] [debug] #1 6964d82a in ?? () from plugins\crashdetect.DLL
[14:10:36] [debug] #2 69654fe8 in ?? () from plugins\crashdetect.DLL
[14:10:36] [debug] #3 6964a1a7 in ?? () from plugins\crashdetect.DLL
[14:10:36] [debug] #4 6964d87a in ?? () from plugins\crashdetect.DLL
[14:10:36] [debug] #5 672c3374 in ?? () from plugins\streamer.DLL
[14:10:36] [debug] #6 69b48893 in ?? () from plugins\mysql.DLL
[14:10:36] [debug] #7 69b665b3 in ?? () from plugins\mysql.DLL
[14:10:36] [debug] #8 69b4c487 in ?? () from plugins\mysql.DLL
[14:10:36] [debug] #9 69b4e3d3 in ?? () from plugins\mysql.DLL
[14:10:36] [debug] #10 00469a66 in ?? () from samp-server.exe
[14:10:36] [debug] #11 0048d4db in ?? () from samp-server.exe
[14:10:36] [debug] #12 0049b531 in ?? () from samp-server.exe
[14:10:36] [debug] #13 0049b541 in ?? () from samp-server.exe
[14:10:36] [debug] Registers:
[14:10:36] [debug] EAX: 0000000a EBX: 00000001 ECX: 00000000 EDX: 00000000
[14:10:36] [debug] ESI: 004f4f80 EDI: 00000035 EBP: 0049b531 ESP: 0019fea0
[14:10:36] [debug] EIP: 0049b541 EFLAGS: 00010206
[14:10:36] [debug] Stack:
[14:10:36] [debug] ESP+00000000: 004ab530 0019ff78 004ab171 ffffffff
[14:10:36] [debug] ESP+00000020: 00000094 00000006 00000002 000023f0
[14:10:36] [debug] ESP+00000040: 00000000 00000000 00000000 00000000
[14:10:36] [debug] ESP+00000060: 00000000 00000000 00000000 00000000
[14:10:36] [debug] ESP+00000080: 00000000 00000000 00000000 00000000
[14:10:36] [debug] ESP+000000a0: 00000000 00000000 00000000 00000000
[14:10:36] [debug] ESP+000000c0: 00000000 00000000 c0000005 00000000
[14:10:36] [debug] ESP+000000e0: 004ba530 00000000 0019ff98 74a816d9
[14:10:36] [debug] ESP+00000100: 00208000 8b8747a1 00000000 00000000
[14:10:36] [debug] ESP+00000120: 00000000 0019ffa4 00000000 0019ffe4
[14:10:36] [debug] ESP+00000140: 77c741b0 ffffffff 77c933e7 00000000
[14:10:36] [debug] ESP+00000160: 78746341 00000020 00000001 00003334
[14:10:36] [debug] ESP+00000180: 00000014 00000001 00000007 00000034
[14:10:36] [debug] ESP+000001a0: 00000000 00000000 00000000 00000002
[14:10:36] [debug] ESP+000001c0: 00000260 00000000 f33271ba 00000540
[14:10:36] [debug] ESP+000001e0: 2d59495b 000008d4 00000032 00000908
[14:10:36] [debug] ESP+00000200: 00000042 00000c4c 00000336 00000000
[14:10:36] [debug] ESP+00000220: 00000368 00000000 b1280544 0000134c
[14:10:36] [debug] ESP+00000240: 00000009 000000ec 00000002 00000001
[14:10:36] [debug] ESP+00000260: 00001774 000007a0 00000001 00000003
[14:10:36] [debug] ESP+00000280: 00002da0 00000314 00000002 00000005
[14:10:36] [debug] ESP+000002a0: 0000314c 000000cc 00000002 00000007
[14:10:36] [debug] ESP+000002c0: 00003308 00000028 00000002 0000000b
[14:10:36] [debug] ESP+000002e0: 0000002c 00000001 00000001 00000001
[14:10:36] [debug] ESP+00000300: 0000002c 0000005e 0000005e 00000000
[14:10:36] [debug] ESP+00000320: 00000000 00000000 00000000 00000000
[14:10:36] [debug] ESP+00000340: 003a0043 0057005c 004e0049 004f0044
[14:10:36] [debug] ESP+00000360: 005c0073 00000000 1a26ef4e 0000011c
[14:10:36] [debug] ESP+00000380: f33271ba 000003c4 0000004a 00000410
[14:10:36] [debug] ESP+000003a0: 00000032 0000078c 00000300 00000003
[14:10:36] [debug] ESP+000003c0: 00000336 00000004 38505fc8 00000e08
[14:10:36] [debug] ESP+000003e0: b1280544 000011d0 00000056 00001228
Y-Less commented 6 years ago

No, that is a bug - inlines should be usable from OnScriptInit. The only rule is that they can't be used from OnCodeInit. That is the special callback reserved for generating code, thus anything that requires generated code can't be used in there.

Y-Less commented 6 years ago

Ok, try this, as I was reminded in your other issue:

https://github.com/pawn-lang/YSI-Includes/blob/5.x/YSI_Coding/y_malloc/faqs.md

George480 commented 6 years ago

This is still an issue. Using y_inline inside OnScriptInit will give run time error but it works alright in OnGameModeInit callback.

I use the latest version of YSI 5 and amx_assembly and the functions from y_inline_extra.inc

Run time error 5: "Invalid memory access"
AMX backtrace:
#0 00009808 in public Indirect_FromCallback () at <...>\YSI_Coding\y_inline\..\y_va\..\..\YSI_Core\y_core\..\..\amx\asm.inc:235

I also tried YSI_NO_HEAP_MALLOC and gives different run time error.

Run time error 6: "Invalid instruction"
Unknown opcode 0xfffffff8 at address 0x00004F54
AMX backtrace:
 #0 00004f54 in public Indirect_FromCallback (F@_@:cb=20308, bool:release=true) at <...>\YSI_Coding\y_malloc\..\..\YSI_Core\y_core\..\..\amx\amx_header.inc:582

Run time error 6: "Invalid instruction"
Unknown opcode 0x3d446d8 at address 0x00004ED4
AMX backtrace:
#0 00004ed4 in public Indirect_FromCallback (F@_@:cb=20180, bool:release=true) at <...>\YSI_Coding\y_malloc\..\..\YSI_Core\y_core\..\..\amx\amx_header.inc:579