Holy moly. It took an hour and a half of stepping through this socket code in gdb to figure out that the stack was being smashed after calling recv because my buffer was too small.

I was gobsmacked when I saw that calling `recv` would suddenly cause a huge chunk of my locals to become 0.... but not all of them! My sleep deprived brain took a second to realize this meant that the stack was being clobbered, and eventually realized that I was reading 512 bytes into a 40 byte buffer 🤦‍♂️
I'm kinda proud of myself for being able to effectively debug with gdb.

Show thread

I just remembered the really weird part! This bug isn't happening on my Ubuntu machine, only on the Red Hat school servers. Why wasn't the stack being smashed there? I'll have to do some detective work in the morning 🧐

Show thread

This bug has made me miss Rust immensely. C is great, but you really shouldn't be able to smash the stack that easily in 2020.

Sign in to participate in the conversation
The Cabal

This is a server created by Jahziel Villasana (aka hapax). He's not sure what he's going to use it for yet...