• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Weird "Illegal size 0" buffer error

Hello,
as stated in the title i get a weird error which is mentioned 3 times on google.

ERROR!!! :: ############################################################################################
FATAL ERROR in
action number 1
of PreCreate Event
for object obj_loading_icon:


buffer_create: Illegal size 0
############################################################################################

I have traced back the line of code which causes this error:
GML:
buffer_seek(buffer, buffer_seek_start, 0);
buffer_write(buffer, buffer_u8, 1);

// if i write a string/text into the buffer the error occures when i send the packet
buffer_write(buffer, buffer_text, global.player_name);
show_debug_message(buffer_tell(buffer));

// this line causes the error when a string is added. Without the string it workes fine
network_send_packet(socket, buffer, buffer_tell(buffer));
All the variables are set up correctly and the code worked fine until today. Everything worked, but then i added some code elsewhere (i dont know what i added before this occured) and now every time i connect to the server it throws this error. The obj_loading_icon has no code in it btw. it is only a object with a sprite that is animated. When i delete the object "obj_loading_icon" the error is thrown from a different object. It sure seems like a bug so i dont think that anyone can help me here. I have another script which sends the player data to the server every fram and when i commet the error causing line out everything works fine and the player data is sent to the server normally without any issue. I still use GameMaker 1.4.9999 which may be the error (i currently cant afford the new GM :( ) The error also only occures ~29/30 times. Sometimes i can join without issue :O

Thanks for reading and maybe you have an idea what i can still try
 
This error is caused by game maker receiving a buffer that claims to be 0 bytes long.

buffer_text (the format you're using to write the username into the buffer) is not null terminated, meaning if global.player_name were to be blank, literally nothing will be written into the buffer. So calling buffer_seek() in this situation would return 0, which is presumably why you get the error message when you send that packet (of 0 length).

GML:
// this line causes the error when a string is added. Without the string it workes fine
network_send_packet(socket, buffer, buffer_tell(buffer));
If you were to use buffer_get_size(buffer) instead of buffer_tell(buffer), this should solve the crash (because it returns the buffer length, not the seek, which will always be a minimum of 1), but it doesn't address the 2 underlying issues here:

1. Why is global.player_name blank 1/30 of the time?
2. Game maker 1.4.9999 will crash any time someone sends a blank packet to anyone. That's pretty bad.
 
Last edited:
Top