Strval segfault?
#1

pawn Код:
#include <a_samp>

main() {
    SetTimerEx("DelayedIp", 1000, false, "s", "127.0.0.1");
}

forward DelayedIp(ip[]);
public DelayedIp(ip[])
{
    printf("%s", ip);
    printf("%d", strval(ip));
}
Quote:

Number of vehicle models: 0
127.0.0.1
[debug] Server crashed while executing test.amx
[debug] AMX backtrace:
[debug] #0 native strval () from samp-server.exe
[debug] #1 0000deec in public DelayedIp (ip[]=@00005324 "127.0.0.1") at test.pwn:12
[debug] Native backtrace:
[debug] #0 0040335f in ?? () from samp-server.exe
[debug] #1 0018fbb4 in ?? ()
[debug] #2 74085b2a in ?? () from plugins\crashdetect.DLL
[debug] #3 004010b6 in ?? () from samp-server.exe
[debug] #4 74099f54 in ?? () from plugins\crashdetect.DLL
[debug] Registers:
[debug] EAX: 00000000 EBX: 00000032 ECX: 0018fb84 EDX: 00000000
[debug] ESI: 00000000 EDI: 00000013 EBP: 00000000 ESP: 0018fbcc
[debug] EIP: 74099f54 EFLAGS: 00010293
[debug] Stack:
[debug] ESP+00000000: 01e2c838 00000013 0018fd58 03e736c4
[debug] ESP+00000020: 0018fc6e 01e2c838 00000000 00405310
[debug] ESP+00000040: 77b0023b 77b0038a 0071f120 0018fc6e
[debug] ESP+00000060: 77b00402 77afe232 77b003d8 774c5712
[debug] ESP+00000080: 00000274 0018fd18 0018fc60 00000000
[debug] ESP+000000a0: 6e4f0000 6c627550 61436369 00326c6c
[debug] ESP+000000c0: 00000000 004aa31e 757b1136 01ef1cf8
[debug] ESP+000000e0: 03e736c4 0018fd58 00000000 01e2c838
[debug] ESP+00000100: 0018fcd8 02661cd0 792379e4 0018fea4
[debug] ESP+00000120: 00000013 0018fd58 03e736c4 0018fd50
[debug] ESP+00000140: 03e736c4 00000003 00000003 02662e80
[debug] ESP+00000160: 00000000 03a60480 00005324 00405320
[debug] ESP+00000180: 00405308 0018fdb4 7409a767 00005324
[debug] ESP+000001a0: 00000001 01e4f95a 0040174f 01e2c838
[debug] ESP+000001c0: 01e2c838 00000001 00000000 00000000
[debug] ESP+000001e0: 01e2c838 0018fdc4 0018fdc4 7409d65a
[debug] ESP+00000200: 01e2c838 0018fe18 00000003 00000001
[debug] ESP+00000220: 00000001 0018fe18 00000003 01efacb8
[debug] ESP+00000240: 00000003 01ef9940 01ef7858 00000000
[debug] ESP+00000260: 00000000 3ba3e685 0048d4db 00000000
[debug] ESP+00000280: 00010101 00000032 00001e61 000000ac
[debug] ESP+000002a0: 00003531 004c4020 004c401c 7efde000
[debug] ESP+000002c0: 0049d208 004ba2f8 ffffffff 0049b4a1
[debug] ESP+000002e0: ffffffff 0049cca6 00000001 01ef2390
[debug] ESP+00000300: 00001db1 00000002 76726553 20656369
[debug] ESP+00000320: 00000000 00000000 00000000 00000000
[debug] ESP+00000340: 00000000 00000000 00000000 00000000
[debug] ESP+00000360: 00000000 00000000 00000000 00000000
[debug] ESP+00000380: 00000000 0049cb52 00000000 00000000
[debug] ESP+000003a0: 00000000 0018fec0 0018f728 0018ffc4
[debug] ESP+000003c0: 757b338a 7efde000 0018ffd4 77b09902
[debug] ESP+000003e0: 7efde000 00000000 00000000 00000000
[debug] Loaded modules:
[debug] 00400000 - 00519000 samp-server.exe
[debug] 77ad0000 - 77c50000 ntdll.dll
[debug] 757a0000 - 758b0000 kernel32.dll
[debug] 77300000 - 77347000 KERNELBASE.dll
[debug] 76050000 - 76c9c000 SHELL32.dll
[debug] 76ef0000 - 76f9c000 msvcrt.dll
[debug] 75740000 - 75797000 SHLWAPI.dll
[debug] 75cf0000 - 75d80000 GDI32.dll
[debug] 775a0000 - 776a0000 USER32.dll
[debug] 75fa0000 - 76041000 ADVAPI32.dll
[debug] 75f80000 - 75f99000 sechost.dll
[debug] 755a0000 - 75690000 RPCRT4.dll
[debug] 753e0000 - 75440000 SspiCli.dll
[debug] 753d0000 - 753dc000 CRYPTBASE.dll
[debug] 77350000 - 7735a000 LPK.dll
[debug] 75690000 - 7572d000 USP10.dll
[debug] 70380000 - 70387000 WSOCK32.dll
[debug] 754d0000 - 75505000 WS2_32.dll
[debug] 77250000 - 77256000 NSI.dll
[debug] 6bd70000 - 6bda2000 WINMM.dll
[debug] 75440000 - 754a0000 IMM32.DLL
[debug] 774b0000 - 7757c000 MSCTF.dll
[debug] 74080000 - 740d0000 crashdetect.DLL
[debug] 74010000 - 74079000 MSVCP100.dll
[debug] 73e80000 - 73f3f000 MSVCR100.dll
[debug] 73fb0000 - 7400a000 streamer.DLL
[debug] 73e10000 - 73e7c000 MSVCP140.dll
[debug] 73f90000 - 73fa4000 VCRUNTIME140.dll
[debug] 73f80000 - 73f84000 api-ms-win-crt-runtime-l1-1-0.dll
[debug] 73d20000 - 73e01000 ucrtbase.DLL
[debug] 73f70000 - 73f73000 api-ms-win-core-timezone-l1-1-0.dll
[debug] 73f60000 - 73f63000 api-ms-win-core-file-l2-1-0.dll
[debug] 73d10000 - 73d13000 api-ms-win-core-localization-l1-2-0.dll
[debug] 751a0000 - 751a3000 api-ms-win-core-synch-l1-2-0.dll
[debug] 73d00000 - 73d03000 api-ms-win-core-processthreads-l1-1-1.dll
[debug] 73cf0000 - 73cf3000 api-ms-win-core-file-l1-2-0.dll
[debug] 73ce0000 - 73ce4000 api-ms-win-crt-string-l1-1-0.dll
[debug] 73cd0000 - 73cd3000 api-ms-win-crt-heap-l1-1-0.dll
[debug] 73cc0000 - 73cc4000 api-ms-win-crt-stdio-l1-1-0.dll
[debug] 73cb0000 - 73cb4000 api-ms-win-crt-convert-l1-1-0.dll
[debug] 73ca0000 - 73ca3000 api-ms-win-crt-locale-l1-1-0.dll
[debug] 73c90000 - 73c95000 api-ms-win-crt-math-l1-1-0.dll
[debug] 73670000 - 73675000 api-ms-win-crt-multibyte-l1-1-0.dll
[debug] 73660000 - 73663000 api-ms-win-crt-time-l1-1-0.dll
[debug] 73650000 - 73653000 api-ms-win-crt-filesystem-l1-1-0.dll
[debug] 73640000 - 73643000 api-ms-win-crt-environment-l1-1-0.dll
[debug] 73520000 - 73523000 api-ms-win-crt-utility-l1-1-0.dll
[debug] 10000000 - 1000f000 sscanf.DLL
[debug] 734c0000 - 73512000 mysql.DLL
[debug] 734a0000 - 734bc000 log-core.dll
[debug] 73050000 - 73131000 libmariadb.dll
[debug] 6fb50000 - 6fb60000 NLAapi.dll
[debug] 6fbc0000 - 6fbd0000 napinsp.dll
[debug] 6fa20000 - 6fa32000 pnrpnsp.dll
[debug] 70910000 - 7094c000 mswsock.dll
[debug] 6fe50000 - 6fe94000 DNSAPI.dll
[debug] 6fa10000 - 6fa18000 winrnr.dll
[debug] 6fe40000 - 6fe46000 rasadhlp.dll
[debug] 708e0000 - 708e5000 wshtcpip.dll
[debug] 706e0000 - 706fc000 IPHLPAPI.DLL
[debug] 706d0000 - 706d7000 WINNSI.DLL
[debug] 6fe00000 - 6fe38000 fwpuclnt.dll
Segmentation fault

Has anyone met with this problem?
Reply
#2

Oh right, the wiki says string param is unusable. My bad. I think one of the fixes.inc or fixes2.inc fixes that
Reply
#3

Also you can't use strval on an IP. At most it will return the first octet.

If you want the numerical value of an IP then you need something like this:
PHP код:
inet_aton(ip[])
{
    new 
octets[4];
    
sscanf(ip"p<.>a<i>[4]"octets);
    
    return 
octets[0] << 24 octets[1] << 16 octets[2] << octets[3];

Reply
#4

I'm using y_utils IPtoInt, i.e
pawn Код:
stock IPToInt(ip[])
{
    new
        ipv = strval(ip) << 24,
        pos = 0;
    while (pos < 15 && ip[pos++] != '.') {}
    ipv += strval(ip[pos]) << 16;
    while (pos < 15 && ip[pos++] != '.') {}
    ipv += strval(ip[pos]) << 8;
    while (pos < 15 && ip[pos++] != '.') {}
    return ipv + strval(ip[pos]);
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)