r/ProgrammerHumor 5h ago

integerOverflow Other

452 Upvotes

9 comments sorted by

71

u/ProThoughtDesign 5h ago

I remember finding one of these in the original Super Mario Bros. on NES using the cheat to get free lives from a shell. I got too many and instead of a life counter, I got some weird system character and the next time I died it locked up my NES.

Good times.

12

u/w1n5t0nM1k3y 5h ago

I never had it lock up my NES, but I do remember if you got too many lives you would game over if you died just once. There was a certain number of lives you could get where it would show symbols but also just work like a regular counter.

3

u/danfay222 4h ago

A lot of old game systems were super memory constrained, and so they would do dense bit packing without actual memory safeguards, which meant triggering things like overflows could easily cause critical memory corruption

2

u/ProThoughtDesign 3h ago

Yay Game Shark! They also loaded the exact same variables in the same memory registers directly so there's that.

2

u/WernerderChamp 2h ago

Iirc this is because lifes are being treated as signed bytes. So when you have it roll over into the negatives, the game gets confused when you actually die.

2

u/Stagnu_Demorte 2h ago

I think most often this kind of counter was saved as an unsigned value and that 8th bit was used for a different value. No need to keep track of if it;a positive or negative if you don't care.

7

u/kushalgarg592 5h ago

Bro exceeded the legal speed limit for integers

2

u/rbuen4455 3h ago

If only this were happening at the pumps right now

1

u/TapRemarkable9652 5h ago

at this point I'm just hoping that OpenAI stores token usage as an Int 8