06.04.2017, 22:56
(
Последний раз редактировалось IstuntmanI; 07.04.2017 в 19:34.
)
I decided to upgrade to the latest MySQL version (after a problem with MySQL public calls in sampGDK). I converted hundreds of lines without any of those regex codes and it took me 2 days (a total of few hours) on a pretty big gamemode (also writing a sampGDK include for MySQL plugin). I see that R40+ is much more organised, passing return values by reference isn't that bad, it actually looks way better when there is a lot of fetch of strings, ints and floats one after one. Multiple result sets, cleanups and other things make R40 worthy of all these conversions.
By the way, in GitHub "a_mysql.inc" is named "a_mysql.inc.in" and it contains this:
you should name it "a_mysql.inc" and try to fix that line. I guess that this is a problem from compiling and that you are aware of it ?
-----------------------------
I have a problem with MySQL plugin in sampGDK:
(I also tried to run an empty gamemode just with the MySQL connection to a MySQL server and it connected fine, without any crash or error, with the regular server files structure.)
I tried to invoke MySQL's natives in a sampGDK gamemode but the whole server crashes at mysql_connect. Here's how I tried to "convert" them using invokeNative:
and here's how I call them:
This is what it prints:
Which means that it crashes on the mysql_connect line. (I even tried without any option_id parameter set and it is still crashing) The invokeNative call looks fine to me.
After which it crashes (info by crashdetect plugin) (I don't know if this helps too much):
Here are the logs generated by log-core:
MySQL-related Server files structure:
Loading order:
EDIT: If I remove the mysql_connect line, it crashes exactly the same at the first mysql_query call. Also, I find it weird that mysql_set_option has the same values in the debug info ("[DEBUG] mysql_set_option(134265809, 5439571)" above). I tried without initing options and setting them and it still crashes.
EDIT 2: Tried to use ProcDump (I have 0 experience in it): "Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access." (I also tried without "const" arguments) It points me to this disassembly:

EDIT 3: I managed to configure MySQL Plugin's project and recompile it, I added few debug prints and I got to the conclusion that it is crashing on line "logger.LogNativeCall(amx, func, params_format);" from "CLog.cpp" .
Few more debugs:
samplog_LogNativeCall, right before "for" loop:
case 's' from that switch:
then it crashes at
in which amx_GetCppString crashes at
before which I had a debug print:
from amxplugin2.cpp.
This means that it gets the address '00000000' from this line:
which probably means that "param" is not set correctly ?
EDIT 4: Well, setting logging to NONE works without any crash (obviously). You should try to fix this, if you have any idea about why it happens and if you can reproduce it.
----------------
EDIT 5: Ok, so I got past those crashes, by disabling the logs. But there's the old problem, which I posted in the sampGDK plugin topic: no callback is called. I replaced the log from "invalid amx instance" with a logprintf, thinking that this is the problem which is stopping callbacks to execute and I was right, I receive "invalid amx instance" for every callback called from my gamemode plugin. I guess that this is because my gamemode is a plugin and not a regular filterscript/gamemode. I simply removed that check for "valid amx instances" from CCallback.cpp and it looks like OnPublicCall is called for them. (I see in AmxLoad this line: "samplog::RegisterAmx(amx);". I wouldn't be surprised if this would be the problem with the logging too. So AmxLoad isn't called for a sampGDK plugin fakeamx in other plugins, if I'm correct)
Can you please do something to fix these things in R41-3 or R42 ? Keeping logs disabled and having those checks removed aren't exactly good solutions. Maybe some function to manually call AmxLoad from MySQL Plugin to add the fakeamx to the valid instances ?
By the way, in GitHub "a_mysql.inc" is named "a_mysql.inc.in" and it contains this:
Quote:
/** * MySQL plugin @MYSQL_PLUGIN_VERSION@ */ |
-----------------------------
I have a problem with MySQL plugin in sampGDK:
(I also tried to run an empty gamemode just with the MySQL connection to a MySQL server and it connected fine, without any crash or error, with the regular server files structure.)
I tried to invoke MySQL's natives in a sampGDK gamemode but the whole server crashes at mysql_connect. Here's how I tried to "convert" them using invokeNative:
Код:
int mysql_init_options( ) { static AMX_NATIVE Native = sampgdk::FindNative( "mysql_init_options" ); return sampgdk::InvokeNative( Native, "" ); } template < class Args > //not sure if the params parameter passing is correct bool mysql_set_option( int option_id, E_MYSQL_OPTION type, Args * params ) { static AMX_NATIVE Native = sampgdk::FindNative( "mysql_set_option" ); return !!sampgdk::InvokeNative( Native, "iir", option_id, ( int ) type, params ); } int mysql_connect( const char host[ ], const char user[ ], const char password[ ], const char database[ ], int option_id = 0 ) { static AMX_NATIVE Native = sampgdk::FindNative( "mysql_connect" ); return sampgdk::InvokeNative( Native, "ssssi", host, user, password, database, option_id ); }
Код:
mysql_log( ALL ); int lConnectOptions = mysql_init_options( ), lPort = 3306, lPoolSize = 4; bool lAutoReconnect = true; sampgdk::logprintf( "OGMI - 1" ); Plugins::MySQL::set_option( lConnectOptions, SERVER_PORT, &lPort ); Plugins::MySQL::set_option( lConnectOptions, AUTO_RECONNECT, &lAutoReconnect ); Plugins::MySQL::set_option( lConnectOptions, POOL_SIZE, &lPoolSize ); sampgdk::logprintf( "OGMI - 2 - Options ID %d", lConnectOptions ); mysql_connect( MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, lConnectOptions ); sampgdk::logprintf( "OGMI - 3" );
Quote:
Originally Posted by server_log.txt
OGMI - 1
OGMI - 2 - Options ID 1 |
After which it crashes (info by crashdetect plugin) (I don't know if this helps too much):
Код:
[debug] Server crashed due to an unknown error [debug] Native backtrace: [debug] #0 5108f48e in ?? () from log-core.dll [debug] #1 5108f607 in ?? () from log-core.dll [debug] #2 5108a975 in ?? () from log-core.dll [debug] #3 77bd7cd0 in ?? () from plugins\mysql.DLL [debug] #4 77beec64 in ?? () from plugins\mysql.DLL [debug] #5 77658a40 in ?? () from plugins\MYGAMEMODE.DLL [debug] #6 776586a8 in ?? () from plugins\MYGAMEMODE.DLL [debug] #7 776507d4 in ?? () from plugins\MYGAMEMODE.DLL [debug] #8 77703492 in ?? () from plugins\MYGAMEMODE.DLL [debug] #9 7773ff5b in ?? () from plugins\MYGAMEMODE.DLL [debug] #10 77834cdd in ?? () from plugins\MYGAMEMODE.DLL [debug] #11 77648cd3 in ?? () from plugins\MYGAMEMODE.DLL [debug] #12 7765784f in ?? () from plugins\MYGAMEMODE.DLL [debug] #13 7764ae43 in ?? () from plugins\MYGAMEMODE.DLL [debug] #14 0046f679 in ?? () from samp-server.exe [debug] #15 65646f6d in ?? () from samp-server.exe [debug] #16 5a472f73 in ?? () from samp-server.exe [debug] #17 61625f53 in ?? () from samp-server.exe [debug] #18 612e6573 in ?? () from samp-server.exe [debug] Registers: [debug] EAX: 00000000 EBX: 00000001 ECX: 00000001 EDX: 00000000 [debug] ESI: 029bae90 EDI: 00000001 EBP: 61625f53 ESP: 00515c0c [debug] EIP: 612e6573 EFLAGS: 00010246 [debug] Stack: [debug] ESP+00000000: 0000786d 00000000 00000000 00000000 [debug] ESP+00000020: 00000000 00000000 00000000 00000000 [debug] ESP+00000040: 00000000 00000000 00000000 00000000 [debug] ESP+00000060: 00000000 00000000 00000000 00000000 [debug] ESP+00000080: 00000000 00000000 00000000 00000000 [debug] ESP+000000a0: 00000000 00000000 00000000 00000000 [debug] ESP+000000c0: 00000000 00000000 00000000 00000000 [debug] ESP+000000e0: 00000000 00000000 00000000 00000000 [debug] ESP+00000100: 00000000 00000000 00000000 00000000 [debug] ESP+00000120: 00000065 00000000 00000000 00000000 [debug] ESP+00000140: 00000000 00000000 00000000 00000000 [debug] ESP+00000160: 00000006 00000002 00000001 023c1850 [debug] ESP+00000180: 00000000 00516020 00000000 00000000 [debug] ESP+000001a0: 00000000 ffffffff ffffffff 00000000 [debug] ESP+000001c0: ffffffff 00000000 00000000 00000000 [debug] ESP+000001e0: 00000000 00000000 00000fa0 ffffffff [debug] ESP+00000200: 00000fa0 ffffffff ffffffff 00000000 [debug] ESP+00000220: ffffffff 00000000 00000000 00000000 [debug] ESP+00000240: 00000000 00000000 00000fa0 ffffffff [debug] ESP+00000260: 00000fa0 ffffffff ffffffff 00000000 [debug] ESP+00000280: ffffffff 00000000 00000000 00000000 [debug] ESP+000002a0: 00000000 00000000 00000fa0 ffffffff [debug] ESP+000002c0: 00000fa0 ffffffff ffffffff 00000000 [debug] ESP+000002e0: ffffffff 00000000 00000000 00000000 [debug] ESP+00000300: 00000000 00000000 00000000 00000000 [debug] ESP+00000320: 00000000 00000000 00000000 ffffff88 [debug] ESP+00000340: 00610064 00640072 00540020 006d0069 [debug] ESP+00000360: 00000000 00000000 00000000 00000000 [debug] ESP+00000380: 00000000 00540047 00200042 00610044 [debug] ESP+000003a0: 006d0069 00000065 00000000 00000000 [debug] ESP+000003c0: 00000000 00030000 00050000 00000003 [debug] ESP+000003e0: 00000001 00000000 00000000 00000000 [debug] Loaded modules: [debug] 00400000 - 00519000 samp-server.exe [debug] 77240000 - 773c3000 ntdll.dll [debug] 75bb0000 - 75c90000 KERNEL32.DLL [debug] 76590000 - 76731000 KERNELBASE.dll [debug] 74680000 - 75a59000 SHELL32.dll [debug] 76c00000 - 76cbe000 msvcrt.dll [debug] 73fb0000 - 73fe6000 cfgmgr32.dll [debug] 75e30000 - 7639e000 windows.storage.dll [debug] 73d80000 - 73f91000 combase.dll [debug] 76f90000 - 77070000 ucrtbase.dll [debug] 75c90000 - 75d51000 RPCRT4.dll [debug] 73d00000 - 73d1e000 SspiCli.dll [debug] 73cf0000 - 73cfa000 CRYPTBASE.dll [debug] 742c0000 - 7431a000 bcryptPrimitives.dll [debug] 75a60000 - 75aa1000 sechost.dll [debug] 76740000 - 76785000 powrprof.dll [debug] 74240000 - 742b7000 advapi32.dll [debug] 76d20000 - 76d66000 shlwapi.dll [debug] 74520000 - 7454b000 GDI32.dll [debug] 77070000 - 771cb000 gdi32full.dll [debug] 763a0000 - 764ff000 USER32.dll [debug] 74660000 - 74675000 win32u.dll [debug] 75e20000 - 75e2d000 kernel.appcore.dll [debug] 74320000 - 743a8000 shcore.dll [debug] 76cc0000 - 76ccf000 profapi.dll [debug] 57ab0000 - 57ab8000 WSOCK32.dll [debug] 70ab0000 - 70ad4000 WINMM.dll [debug] 771d0000 - 77233000 WS2_32.dll [debug] 00670000 - 00693000 WINMMBASE.dll [debug] 75d60000 - 75d85000 IMM32.DLL [debug] 510a0000 - 510f0000 crashdetect.DLL [debug] 77ce0000 - 77d49000 MSVCP100.dll [debug] 77c20000 - 77cdf000 MSVCR100.dll [debug] 77bc0000 - 77c15000 mysql.DLL [debug] 77ae0000 - 77bbe000 libmariadb.dll [debug] 51080000 - 5109e000 log-core.dll [debug] 65100000 - 6516d000 MSVCP140.dll [debug] 650e0000 - 650f5000 VCRUNTIME140.dll [debug] 70070000 - 70082000 napinsp.dll [debug] 70050000 - 70066000 pnrpnsp.dll [debug] 70030000 - 70044000 NLAapi.dll [debug] 73b30000 - 73b7e000 mswsock.dll [debug] 6fba0000 - 6fc1d000 DNSAPI.dll [debug] 74220000 - 74227000 NSI.dll [debug] 73c00000 - 73c2f000 IPHLPAPI.DLL [debug] 73aa0000 - 73aac000 winrnr.dll [debug] 73010000 - 73021000 wshbth.dll [debug] 73b80000 - 73b88000 rasadhlp.dll [debug] 77a80000 - 77ad7000 streamer.DLL [debug] 10000000 - 1000d000 sscanf.DLL [debug] 77e00000 - 77e0d000 gvar.DLL [debug] 77630000 - 77a73000 MYGAMEMODE.DLL [debug] 73a80000 - 73a96000 sslsp105.dll [debug] 76e10000 - 76f8d000 CRYPT32.dll [debug] 75e10000 - 75e1e000 MSASN1.dll [debug] 70180000 - 701c9000 fwpuclnt.dll [debug] 71cd0000 - 71ceb000 bcrypt.dll
Quote:
Originally Posted by logs\log-core.log
[ERROR] exception 0XC0000005 (ACCESS_VIOLATION) from Vectored Exception Handler catched; shutting log-core down
|
Quote:
Originally Posted by logs\errors.log
[log-core] exception 0XC0000005 (ACCESS_VIOLATION) from Vectored Exception Handler catched; shutting log-core down
|
Quote:
Originally Posted by logs\plugins\mysql.log
[INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[DEBUG] mysql_init_options() [INFO] Options instance with id '1' successfully created. [DEBUG] mysql_init_options: return value: '1' [DEBUG] mysql_set_option(134265809, 5439571) [DEBUG] mysql_set_option: return value: '1' [DEBUG] mysql_set_option(134265809, 5439571) [DEBUG] mysql_set_option: return value: '1' [DEBUG] mysql_set_option(134265809, 5439571) [DEBUG] mysql_set_option: return value: '1' |
Код:
samp-server.exe log-core.dll libmariadb.dll [..] /plugins/ mysql.dll MYGAMEMODE.dll
Quote:
Originally Posted by server.cfg
plugins crashdetect mysql [..] MYGAMEMODE
|
EDIT 2: Tried to use ProcDump (I have 0 experience in it): "Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access." (I also tried without "const" arguments) It points me to this disassembly:

EDIT 3: I managed to configure MySQL Plugin's project and recompile it, I added few debug prints and I got to the conclusion that it is crashing on line "logger.LogNativeCall(amx, func, params_format);" from "CLog.cpp" .
Few more debugs:
samplog_LogNativeCall, right before "for" loop:
Quote:
Debug: module 'plugins/mysql' - name 'mysql_connect' - params_format 'ss*sd' - params '00825678' |
Quote:
Debug: case 's': params_format: 's' - current param: '134248417' - amx '02C69BC0' // if you ask me, I don't think the 'current param' looks fine |
Код:
fmt_msg << '"' << amx_GetCppString(amx, current_param) << '"';
Код:
amx_GetString(&string[0], addr, 0, len + 1);
Quote:
Debug: param '134248417' - addr '00000000' - len '0' |
This means that it gets the address '00000000' from this line:
Код:
amx_GetAddr(amx, param, &addr);
EDIT 4: Well, setting logging to NONE works without any crash (obviously). You should try to fix this, if you have any idea about why it happens and if you can reproduce it.
----------------
EDIT 5: Ok, so I got past those crashes, by disabling the logs. But there's the old problem, which I posted in the sampGDK plugin topic: no callback is called. I replaced the log from "invalid amx instance" with a logprintf, thinking that this is the problem which is stopping callbacks to execute and I was right, I receive "invalid amx instance" for every callback called from my gamemode plugin. I guess that this is because my gamemode is a plugin and not a regular filterscript/gamemode. I simply removed that check for "valid amx instances" from CCallback.cpp and it looks like OnPublicCall is called for them. (I see in AmxLoad this line: "samplog::RegisterAmx(amx);". I wouldn't be surprised if this would be the problem with the logging too. So AmxLoad isn't called for a sampGDK plugin fakeamx in other plugins, if I'm correct)
Can you please do something to fix these things in R41-3 or R42 ? Keeping logs disabled and having those checks removed aren't exactly good solutions. Maybe some function to manually call AmxLoad from MySQL Plugin to add the fakeamx to the valid instances ?