Quick answer: GameMaker buffer_read returning garbage or crashing on incoming packets? You’re reading past the buffer’s tell, or reading types that don’t match the write side — align reads with writes.

A multiplayer game crashes on a malformed packet. The read side calls buffer_read(buf, buffer_string) on a buffer that doesn’t actually have a null terminator.

Match Read and Write Types

Both sides must use the same buffer types in the same order. A buffer_write(..., buffer_u8, 5) followed by buffer_read(..., buffer_u16) on the receiver reads 16 bits and slides the cursor — everything after is garbage.

Length-Prefix Strings

// write
buffer_write(buf, buffer_u16, string_length(s));
buffer_write(buf, buffer_text, s);
// read
var n = buffer_read(buf, buffer_u16);
var s = buffer_read_text(buf, n);

Length-prefixed strings survive missing null terminators and avoid over-reads.

Bounds Check

Compare buffer_tell to buffer_get_size before each read. Drop the packet if it’s short — don’t crash on a malformed network input.

Verifying

Send a malformed / truncated packet to the server. It logs and discards rather than corrupting state or crashing.

“Network buffer reads need exact type alignment, length-prefixed strings, and bounds checks.”

Build a tiny “packet view” debug tool that hex-dumps incoming buffers — saves hours of guesswork on protocol mismatches.