Squirrel print() function crashes when printing >514 chars

Started by vcmptr, Mar 06, 2015, 09:50 PM

Previous topic - Next topic

vcmptr

If print() length greater than 514 characters server crashes.
I have try this:
print("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eie");
My English is not good.

.

#1
Aah yes, the internal implementation of that isn't very pretty and the initial buffer is set to 512 characters. Probably something goes wrong when resizing that buffer to adjust for the new size. I'd suggest std::vector<char> buffer; instead of malloc(); in that implementation. Makes things more easy to control and upon failed resize(); that vector reacts much better :)

At least when that vector fails to resize you can react to that and still keep the old incomplete string instead of a crash. But I might be wrong and there's something else causing the problems here. Anyway, I don't plan on bothering about it. If you need a 512+ characters message then you're doing something wrong :P
.

Kratos_


Quote from: S.L.C on Mar 06, 2015, 10:34 PMIf you need a 512+ characters message then you're doing something wrong
In the middle of chaos , lies opportunity.

vcmptr

Yes I need 512 characters for errors. I'm using this. In some cases errors can be longer than 512 characters.
My English is not good.

MacTavish

I am not sure it can be done or not its just and Idea. If error is big more than 512 chars then why dont you try to joint double print

I don't know how to make code. its an example

if ( error.len () >= 1024)
{
print( 512 error chars here ); print( and 512 error chars here );
}
else print ( if less then 512 chars here );

I really dont know it can be done or not But maybe you guys can make it

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

#5
Quote from: Beztone on Mar 07, 2015, 10:02 AMI really dont know it can be done or not But maybe you guys can make it

Truth is you can't really control or know the final size of a printf message. Also the reason why the internal implementation also has to do some tricks to adjust in case the initial buffer size is small. On your side however, you know the size of the strings that you'll format since I'm imagining that those are quite big. And you could format them in segments then add them all in one big string. However, my advice is that you shouldn't complicate your self too much because this bug will eventually get fixed. And shouldn't be too hard to fix it. I'm too lazy right now to bother making a pull request :D
.

Sk

string.slice(starting_point,ending_point);
can do the job + you will need to add some checks about size and about slicing the text but i guess its better to wait for devs to fix it.

vcmptr

#7
Thank you S.L.C, Kratos, Gudio and Sk. :) And Beztone.
 I will wait fix.
My English is not good.

MacTavish

Quote from: vcmptr on Mar 07, 2015, 05:19 PMThank you S.L.C, Kratos, Gudio and Sk. :) I will wait fix.

Where is He ???

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

vcmptr

@stormeus  It's still crashing server.
My English is not good.