valstr() Bug
#1

I've been struggling for days now why my script keeps hanging during runtime, and found out that the native called valstr() was hanging my whole script.
If you actually try to convert large numbers into strings using valstr(), you can hang your script.

pawn Код:
new my_string[11];
print(" Debug 1");
valstr(my_string, 2080374655); // Valid number, hangs
print(" Debug 2");
prints
Код:
 Debug 1
After that the server becomes not enterable, and this appears:
Код:
Incoming connection: <IP>:<port>
Kicking <IP> because they didn't logon to the game.
I had to avoid this issue by using something like
pawn Код:
format(my_string, sizeof my_string, "%d", 2080374655);
which works fine.

Best Regards

~ BigETI
Reply
#2

thanks for the inforamation though i mostly used format for int to str
Reply
#3

High values passed to this function can cause the server to freeze for no apparent reason. If this happens, then use format instead.
Reply
#4

The highest value it accepts is 1874919423. For this reason I wouldn't use it at all; having to add checks to stop these errors outweighs the penalty of resorting to format.
Reply
#5

This is nonsense. It should atleast support all values between -2147483648 and 2147483647.
Reply
#6

https://sampforum.blast.hk/showthread.php?pid=1790300#pid1790300

I'm trying some custom functions now, but I doubt they'll be faster.

E: Yup, up to 5x slower.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)