CreateFamilyCar
#1

Hello, So today, I've got a function that crashes the server whenever we try to perform it in game..

Function:

PHP код:
CreateFamilyCar(famidmodelc1c2ELockType:lockFloat:XFloat:YFloat:ZFloat:Angle) {
    
#pragma unused lock
    //query[0] = 0;//[256];
    
new query[256];
    
mysql_real_escape_string(modelmodel)
    
format(querysizeof(query), "INSERT INTO familycars (model,colour1,colour2,X,Y,Z,Angle,owner) VALUES (%d,%d,%d,%f,%f,%f,%f,%d)",model,c1,c2,X,Y,Z,Angle,famid);
    
mysql_function_query(g_mysql_handlequerytrue"onCreateFamilyVehicle""ddddffff"famidmodelc1c2XYZAngle);

onCreateFamilyVehicle..

PHP код:
public onCreateFamilyVehicle(famidmodelc1c2Float:XFloat:YFloat:ZFloat:Angle) {
    new 
id;
    
id mysql_insert_id();
    new 
carid CreateVehicle(model,X,Y,Z,Angle,c1,c2,DEF_RESPAWN_DELAY);
    if(!
IsACar(GetVehicleModel(carid))) {
        
VehicleInfo[carid][EVEngine] = 1;
    } else {
        
VehicleInfo[carid][EVEngine] = 0;
    }
    new 
engine,lights,alarm,doors,bonnet,boot,objective;
    
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
    
VehicleInfo[carid][EVLocked] = 1;
    
SetVehicleParamsEx(carid,VehicleInfo[carid][EVEngine],lights,alarm,VehicleInfo[carid][EVLocked],bonnet,boot,objective);
    
VehicleInfo[carid][EVToDelete] = 0;
    
VehicleInfo[carid][EVOwner] = famid;
    
VehicleInfo[carid][EVColour][0] = c1;
    
VehicleInfo[carid][EVColour][1] = c2;
    
VehicleInfo[carid][EVFuel] = 100;
    
VehicleInfo[carid][EVLockType] = ELockType_Default;
    
VehicleInfo[carid][EVSQLID] = id;
    
VehicleInfo[carid][EVType] = EVehicleType_Family;
    
VehicleInfo[carid][EVRadioStation] = -1;
    
VehicleInfo[carid][EVFlags] = EVehicleFlags:0;
    
clearTrunk(carid);
    
format(VehicleInfo[carid][EVPlate],32,"NCRP");
    
SetVehicleNumberPlate(caridVehicleInfo[carid][EVPlate]);
    return 
1;

Crash Log:

Quote:

[11:48:06] [debug] Server crashed while executing WCRP.amx
[11:48:06] [debug] AMX backtrace:
[11:48:06] [debug] #0 native mysql_function_query () from mysql.so
[11:48:06] [debug] #1 000a719c in ?? (3, 411, 0, 1, 1, 1156145846, -993482291, 1096335360, 1131428199) from WCRP.amx
[11:48:06] [debug] #2 0008f8c4 in ?? (0, 5958864, 0) from WCRP.amx
[11:48:06] [debug] #3 0008f4b8 in public @yC_createfamilycar (0, 5958864, 0, 0) from WCRP.amx
[11:48:06] [debug] #4 native CallRemoteFunction () from samp03svr
[11:48:06] [debug] #5 00018a54 in ?? (0, 5958748, 0) from WCRP.amx
[11:48:06] [debug] #6 0001835c in public OnPlayerCommandText (0, 595874 from WCRP.amx
[11:48:06] [debug] Native backtrace:
[11:48:06] [debug] #0 f73cd180 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[11:48:06] [debug] #1 f73c5064 in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7C ontextE () from plugins/crashdetect.so
[11:48:06] [debug] #2 f73c5d64 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7Cont extE () from plugins/crashdetect.so
[11:48:06] [debug] #3 f73c7cdb in _ZN11CrashDetect7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[11:48:06] [debug] #4 f73cc4d5 in ?? () from plugins/crashdetect.so
[11:48:06] [debug] #5 f7727d50 in __kernel_rt_sigreturn () from linux-gate.so.1
[11:48:06] [debug] #6 f7727d70 in __kernel_vsyscall () from linux-gate.so.1
[11:48:06] [debug] #7 f7424367 in gsignal () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] #8 f7425a23 in abort () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] #9 f7462778 in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] #10 f74687ea in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] #11 f746943d in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] #12 f7084779 in _ZN7Natives22n_mysql_query_callbackEP6tagAMXPi () from plugins/mysql.so
[11:48:06] [debug] #13 080950e4 in ?? () from ./samp03svr
[11:48:06] [debug] #14 f73c6ad3 in _ZN11CrashDetect17HandleAMXCallbackEiPiS0_ () from plugins/crashdetect.so
[11:48:06] [debug] #15 0000000b in ?? () from *зnчHеnчL‰!
[11:48:06] [debug] L‰!
[11:48:06] [debug] MЌ!
[11:48:06] [debug] L‰!
[11:48:06] [debug] МЌ!
[11:48:06] [debug] L‘!
[11:48:06] [debug] toч
[11:48:06] [debug] Registers:
[11:48:06] [debug] EAX: 00000000 EBX: 00000887 ECX: 00000887 EDX: 00000006
[11:48:06] [debug] ESI: 0000004d EDI: f759f000 EBP: fff03c18 ESP: fff03954
[11:48:06] [debug] EIP: f7727d70 EFLAGS: 00000296
[11:48:06] [debug] Stack:
[11:48:06] [debug] ESP+00000000: fff03c18 00000006 00000887 f7424367
[11:48:06] [debug] ESP+00000020: fff03984 00000000 f76f87f0 08049afd
[11:48:06] [debug] ESP+00000040: 00000000 00000000 00000000 00000000
[11:48:06] [debug] ESP+00000060: 00000000 00000000 00000000 00000000
[11:48:06] [debug] ESP+00000080: 00000000 00000000 00000000 00000000
[11:48:06] [debug] ESP+000000a0: 00000000 00000000 00000000 00000000
[11:48:06] [debug] ESP+000000c0: 00000001 00000000 00000000 00000000
[11:48:06] [debug] ESP+000000e0: f77339aa fff03aa0 08049150 fff03aa8
[11:48:06] [debug] ESP+00000100: 00000000 00000001 f774b930 00000000
[11:48:06] [debug] ESP+00000120: f774b000 f72c0864 00000000 00000003
[11:48:06] [debug] ESP+00000140: f759f000 00000007 f7462778 0000000c
[11:48:06] [debug] ESP+00000160: 00000000 00000006 fff03af0 f755a9bc
[11:48:06] [debug] ESP+00000180: 00000003 f755ab5c 00000020 f755a9d1
[11:48:06] [debug] ESP+000001a0: 00000005 f774bae8 f76f8c28 00000001
[11:48:06] [debug] ESP+000001c0: 00000005 fff03b30 f7469afc 080494b0
[11:48:06] [debug] ESP+000001e0: 00000008 fff03b50 f72c0fe0 fff03ba8
[11:48:06] [debug] ESP+00000200: 00000004 fff03b70 00000003 00000028
[11:48:06] [debug] ESP+00000220: 00000020 fff03b90 0000006e 00000000
[11:48:06] [debug] ESP+00000240: 00000003 fff03bb0 f759f000 f759f420
[11:48:06] [debug] ESP+00000260: 0000000b fff03bd0 fff03d78 00000902
[11:48:06] [debug] ESP+00000280: 0000000e 00000000 f745b782 f7651017
[11:48:06] [debug] ESP+000002a0: 0000004d 0000004d 00000007 f76b4e57
[11:48:06] [debug] ESP+000002c0: fff06b40 f759f420 f74687ea 00000001
[11:48:06] [debug] ESP+000002e0: 00000000 00000002 f755ab5c 00000000
[11:48:06] [debug] ESP+00000300: 0a05b308 00000010 f746943d 0a05b308
[11:48:06] [debug] ESP+00000320: f559364c f76b5789 f76f0000 fff03d24
[11:48:06] [debug] ESP+00000340: 00000000 00000000 0a05b308 0000000c
[11:48:06] [debug] ESP+00000360: f716b29d f76b57f9 0a05b308 fff03d64
[11:48:06] [debug] ESP+00000380: 0a05b308 0000000c c0991539 fff03d20
[11:48:06] [debug] ESP+000003a0: 00000005 00000000 00000000 0a0ab1b0
[11:48:06] [debug] ESP+000003c0: 0a05ed8c 0a0582c4 0a05aeb4 0a11bd94
[11:48:06] [debug] ESP+000003e0: 081a199c 081a199c 081a199c 081a199c
[11:48:06] [debug] Loaded modules:
[11:48:06] [debug] 00000000 - 00187dc3 samp03svr
[11:48:06] [debug] f7727000 - f7727e96 linux-gate.so.1
[11:48:06] [debug] f7715000 - f771781b /lib/i386-linux-gnu/i686/cmov/libdl.so.2
[11:48:06] [debug] f76f9000 - f7713d2b /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
[11:48:06] [debug] f7606000 - f76ffce6 /usr/lib32/libstdc++.so.6
[11:48:06] [debug] f75c0000 - f7604b43 /lib/i386-linux-gnu/i686/cmov/libm.so.6
[11:48:06] [debug] f75a3000 - f75bf3c4 /lib/i386-linux-gnu/libgcc_s.so.1
[11:48:06] [debug] f73f6000 - f75ab22f /lib/i386-linux-gnu/i686/cmov/libc.so.6
[11:48:06] [debug] f772a000 - f774ad6c /lib/ld-linux.so.2
[11:48:06] [debug] f73af000 - f73f1ac4 plugins/crashdetect.so
[11:48:06] [debug] f72f1000 - f73af39a plugins/streamer.so
[11:48:06] [debug] f771b000 - f772209f /lib/i386-linux-gnu/i686/cmov/librt.so.1
[11:48:06] [debug] f72d0000 - f72f01ed plugins/dns.so
[11:48:06] [debug] f72c0000 - f72cf1d4 plugins/sscanf.so
[11:48:06] [debug] f72b4000 - f72bd918 plugins/Whirlpool.so
[11:48:06] [debug] f6ff0000 - f72b707c plugins/mysql.so
[11:48:06] [debug] f6fd8000 - f6fe33ef /lib/i386-linux-gnu/i686/cmov/libnss_files.so.2
[11:48:06] [debug] f6fec000 - f6fedf70 plugins/nativechecker.so
[11:48:06] [debug] f6fe5000 - f6fe997b /lib/i386-linux-gnu/i686/cmov/libnss_dns.so.2
[11:48:06] [debug] f6766000 - f677e2fb /lib/i386-linux-gnu/i686/cmov/libresolv.so.2

help?
Reply
#2

Bump
Reply
#3

The function is called mysql_real_escape_string. Not mysql_real_escape_integer. You only need to escape text. Consider upgrading the plugin in the near future, though. You're already using threaded queries so implementing the changes shouldn't be incredibly hard.
Reply
#4

Ahh, So that is the reason causing crash? Now I got it, Alright, I'm gonna fix it up.
Reply
#5

Having taken a brief look at your query, I've noticed that there isn't a semi-colon after the line, "mysql_real_escape_string(model, model) ".
I would also like to ask why you would try to escape the variable model as I assume it would be an integer anyway. I would suggest commenting that line out and see what happens.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)