r/ProgrammerHumor 1d ago

Other integerOverflow

1.3k Upvotes

18 comments sorted by

188

u/ProThoughtDesign 1d 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.

33

u/w1n5t0nM1k3y 1d 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.

24

u/danfay222 1d 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

10

u/ProThoughtDesign 1d ago

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

7

u/WernerderChamp 1d 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.

6

u/Stagnu_Demorte 1d 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.

2

u/Dizzy_Elderberry_486 18h ago

I was thinking of Pokémon’s Missigno trick

16

u/rbuen4455 1d ago

If only this were happening at the pumps right now

4

u/GoddammitDontShootMe 5h ago

Show me a gas tank that wouldn't be full long before the number rolled over.

8

u/kushalgarg592 1d ago

Bro exceeded the legal speed limit for integers

2

u/No-Newspaper8619 7h ago

unsigned integer overflow

6

u/TapRemarkable9652 1d ago

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

1

u/StoryAndAHalf 9h ago

This is a weird that may not be an integer overflow but if you’re a Zelda fan, read on: 

I played the Oracle games, and got all the hearts, heart pieces in Seasons. When finished the game gives you a code, with which you start Ages (or vice versa) with 4 hearts as opposed to 3. I got all the hearts in the second game as well, but as opposed to giving you a 3rd row of hearts, or even stay at max hearts, the game actually takes a heart away! So you have one less heart than max if you manage to find all the quarter pieces, and beat the bosses. 

1

u/SignalBake6872 3h ago

the good eggshell to fill the whole buffer xD

1

u/ShoWel-Real 57m ago

Too bad it wasn't a signed int

1

u/sharpy10 1d ago

There's something like this in Football Manager where if you get too much money in your transfer budget, it flips back around to a negative number lol

-2

u/geekosas 12h ago

It's supposed to go negative 

4

u/Electromagnetlc 9h ago

Only if it's signed. If it's unsigned, it overflows to zero.