SA-MP Forums Archive
Maybe SA:MP BUG ??? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Maybe SA:MP BUG ??? (/showthread.php?tid=326324)



Maybe SA:MP BUG ??? - dudaefj - 17.03.2012

It's making me crazy...

how is possible fwrite to make a server crash?

Oh, ok. I know fopen in io_read method can do this, bug... fwrite? how??

And even when the same code happens a lot of times, it works 99% of them, and 1% it makes server crash, WTF!? o.O


look at this code:


PHP код:
stock WriteLog(filename[],text[])
{
    
printf("%s => %s"filenametext);
    new 
File:file;
    new 
filepath[60], string[256], year,day,monthhour,minute,second;
    
getdate(year,month,day); gettime(hour,minute,second);
    
format(filepath,sizeof(filepath),"RPG/logs/%s.log",filename);
    
file fopen(filepath,io_append);
    
format(string,sizeof(string),"[%02d/%02d/%d|%02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
    
fwrite(file,string);
    
fclose(file);
    return 
1;
}
#define FormatLog(%1,%2,%3) do{new _string[128]; format(_string,sizeof(_string),%2,%3); WriteLog(%1, _string);} while(False)
public ABroadCast(color,const string[],level)
{
    
FormatLog("abroadcast""%s"string);
    foreach(
Playeri)
        if(
Admins[Player[i][pAdminID]][aLevel] >= level || Player[i][pEnigma] > 0)
            
SendClientMessage(icolorstring);
    return 
1;

Log:

Quote:

[14/03/12 22:18:11] abroadcast => [RELATOS] Cesar_Medeiros (id: 5) relatou: como ganha cash?
[14/03/12 22:18:11] [debug] Server crashed while executing BSL2.amx
[14/03/12 22:18:11] [debug] Backtrace (most recent call first):
[14/03/12 22:18:11] [debug] #0 ?? in native fwrite () from samp-server.exe
[14/03/12 22:18:12] [debug] #1 00138d58 in WriteLog (filename[]=@0x00362b58 "abroadcast", text[]=@0x0049c624 "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:18:12] [debug] #2 000a49fc in public ABroadCast (color=3550040, string[]=@0x0049c624 "", level=91) at C:\xxxx\gamemodes\BSL2.pwn:16096
[14/03/12 22:18:12] [debug] #3 001cfe84 in dcmd_relato (playerid=3550040, params[]=@0x0049c624 "") at C:\xxxx\gamemodes\BSL2.pwn:38799
[14/03/12 22:18:12] [debug] #4 0011244c in dcmd_relatorio (playerid=3550040, params[]=@0x0049c624 "") at C:\xxxx\gamemodes\BSL2.pwn:21229
[14/03/12 22:18:12] [debug] #5 001024f8 in public OnPlayerCommandText (playerid=3550040, cmdtext[]=@0x0049c624 "") at C:\xxxx\gamemodes\BSL2.pwn:21017


Other exemple (that is the only one that get something not null on ext[]="...":
Quote:

[15/03/12 23:37:39] sms => [SMS] lug_Lucas: pilantra eh a mгe, atirei no teu amigo porque ele atirou em mim |Danrley_FC(Tel:11535)
[15/03/12 23:37:39] [debug] Server crashed while executing BSL2.amx
[15/03/12 23:37:39] [debug] Backtrace (most recent call first):
[15/03/12 23:37:39] [debug] #0 ?? in native fwrite () from samp-server.exe
[15/03/12 23:37:39] [debug] #1 00138d58 in WriteLog (filename[]=@0x003de4b4 "sms", text[]=@0x00080ca4 "[SMS] lug_Lucas: pilantra eh a...") at C:\xxxx\gamemodes\BSL2.pwn:24724
[15/03/12 23:37:39] [debug] #2 0017d058 in dcmd_sms (playerid=4056244, params[]=@0x00080ca4 "[SMS] lug_Lucas: pilantra eh a...") at C:\xxxx\gamemodes\BSL2.pwn:31094
[15/03/12 23:37:39] [debug] #3 000e6758 in public OnPlayerCommandText (playerid=4056244, cmdtext[]=@0x00080ca4 "[SMS] lug_Lucas: pilantra eh a...") at C:\xxxx\gamemodes\BSL2.pwn:20700


a lot of other exemples if someone want:
PHP код:
[14/03/12 22:19:42connections => matador2000 conectou no servidor. (id24 IP189.182.98.225)
[
14/03/12 22:19:42] [debugServer crashed while executing BSL2.amx
[14/03/12 22:19:42] [debugBacktrace (most recent call first):
[
14/03/12 22:19:42] [debug#0  ???????? in native fwrite () from samp-server.exe
[14/03/12 22:19:42] [debug#1  00138d58 in WriteLog (filename[]=@0x0034b610 "connections", text[]=@0x0049c3c8 "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:19:42] [debug#2  0005f198 in public Itter_OnPlayerConnect (playerid=3454480) at C:\xxxx\gamemodes\BSL2.pwn:10185
[14/03/12 22:19:42] [debug#3  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:19:42] [debug#4  000067b0 in public Streamer_OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\foreach.inc:479
[14/03/12 22:19:42] [debug#5  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:19:42] [debug#6  000061d8 in public OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\streamer.inc:299
[14/03/12 22:20:24connections => Jhon_Cena conectou no servidor. (idIP187.19.237.172)
[
14/03/12 22:20:24] [debugServer crashed while executing BSL2.amx
[14/03/12 22:20:24] [debugBacktrace (most recent call first):
[
14/03/12 22:20:24] [debug#0  ???????? in native fwrite () from samp-server.exe
[14/03/12 22:20:24] [debug#1  00138d58 in WriteLog (filename[]=@0x0034b610 "connections", text[]=@0x0049c3c8 "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:20:24] [debug#2  0005f198 in public Itter_OnPlayerConnect (playerid=3454480) at C:\xxxx\gamemodes\BSL2.pwn:10185
[14/03/12 22:20:24] [debug#3  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:20:24] [debug#4  000067b0 in public Streamer_OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\foreach.inc:479
[14/03/12 22:20:24] [debug#5  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:20:24] [debug#6  000061d8 in public OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\streamer.inc:299
[14/03/12 22:21:02connections => John_White conectou no servidor. (idIP187.75.64.149)
[
14/03/12 22:21:02] [debugServer crashed while executing BSL2.amx
[14/03/12 22:21:02] [debugBacktrace (most recent call first):
[
14/03/12 22:21:02] [debug#0  ???????? in native fwrite () from samp-server.exe
[14/03/12 22:21:02] [debug#1  00138d58 in WriteLog (filename[]=@0x0034b610 "connections", text[]=@0x0049c3c8 "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:21:02] [debug#2  0005f198 in public Itter_OnPlayerConnect (playerid=3454480) at C:\xxxx\gamemodes\BSL2.pwn:10185
[14/03/12 22:21:02] [debug#3  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:21:02] [debug#4  000067b0 in public Streamer_OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\foreach.inc:479
[14/03/12 22:21:02] [debug#5  ???????? in native CallLocalFunction () from samp-server.exe
[14/03/12 22:21:02] [debug#6  000061d8 in public OnPlayerConnect (playerid=3454480) at C:\sampserver\pawno\include\streamer.inc:299
[14/03/12 22:22:05Radio => (RadioCapitгo QRA_LukeAmr eu vou saircвmbio.
[
14/03/12 22:22:05] [debugServer crashed while executing BSL2.amx
[14/03/12 22:22:05] [debugBacktrace (most recent call first):
[
14/03/12 22:22:05] [debug#0  ???????? in native fwrite () from samp-server.exe
[14/03/12 22:22:05] [debug#1  00138d58 in WriteLog (filename[]=@0x0045e3b4 "Radio", text[]=@0x0049c638 "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:22:05] [debug#2  00223c60 in dcmd_radio (playerid=4580276, params[]=@0x0049c638 "") at C:\xxxx\gamemodes\BSL2.pwn:45548
[14/03/12 22:22:05] [debug#3  00223980 in dcmd_r (playerid=4580276, params[]=@0x0049c638 "") at C:\xxxx\gamemodes\BSL2.pwn:45529
[14/03/12 22:22:05] [debug#4  000e2dd8 in public OnPlayerCommandText (playerid=4580276, cmdtext[]=@0x0049c638 "") at C:\xxxx\gamemodes\BSL2.pwn:20658
[14/03/12 22:23:28Radio => (RadioIniciante OTAK_ADVANCEDAQUI O SERV TA PESSIMOcвmbio.
[
14/03/12 22:23:28] [debugServer crashed while executing BSL2.amx
[14/03/12 22:23:28] [debugBacktrace (most recent call first):
[
14/03/12 22:23:28] [debug#0  ???????? in native fwrite () from samp-server.exe
[14/03/12 22:23:28] [debug#1  00138d58 in WriteLog (filename[]=@0x0045e3b4 "Radio", text[]=@0x0049c64c "") at C:\xxxx\gamemodes\BSL2.pwn:24724
[14/03/12 22:23:28] [debug#2  00223c60 in dcmd_radio (playerid=4580276, params[]=@0x0049c64c "") at C:\xxxx\gamemodes\BSL2.pwn:45548
[14/03/12 22:23:28] [debug#3  000f0578 in public OnPlayerCommandText (playerid=4580276, cmdtext[]=@0x0049c64c "") at C:\xxxx\gamemodes\BSL2.pwn:20813 





I tought that it could be some "forbidden" char, so I did:

Код:
#include <a_samp>

public OnGameModeInit() 
{
    new string[300];
    for(new i = 0; i < 3000; i++)
    {
        printf("i = %d", i);
        format(string,sizeof(string),"%s",i);
        WriteLog("aaaaa",string);
    }
    return 1;
}

stock WriteLog(filename[],text[])
{
	printf("%s => %s", filename, text);
	new File:file;
	new filepath[60], string[256], year,day,month, hour,minute,second;
	getdate(year,month,day); gettime(hour,minute,second);
	format(filepath,sizeof(filepath),"%s.log",filename);
	file = fopen(filepath,io_append);
	format(string,sizeof(string),"[%02d/%02d/%d|%02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
	fwrite(file,string);
	fclose(file);
	return 1;
}
but nothing about crash, just a crazy sound and the server stopped responding (and I had to press ctrl+alt+del, but it didnt crash)