How malloc broke Serenity's JPGLoader, or: how to win the lottery - sin-ack's writings

I got the chance to investigate an interesting bug in SerenityOS this week. It was related to the decoding of JPG images in the operating system. For some reason, when a JPG image is viewed, it comes out like this: Lenna, showing up with incorrect colors. Weird, huh? Also seems like a simple confusi...

Click to view the original at

Hasnain says:

As an HN commenter alludes, this is why hashmaps should explicitly always randomize iteration order (at least in test mode) so people don’t rely on this behavior. It was surprising how many bugs shook out when we did this at FB

“Thanks to CxByte, Gunnar, Andrew and Brian for their help with debugging this, and their helpful tips. Gunnar in particular was the one who uncovered this bug, and despite my satirical jab in the commit message helped uncover this very interesting bug, so he’s the one who made this post possible.

Also, thanks to the person who introduced this bug (the commit log gets a little fuzzy, so I’m not quite sure who did) and hope he buys a lottery ticket. :^)”

Posted on 2024-07-07T17:26:09+0000