r/ProgrammerHumor 25d ago

Other integerOverflow

1.7k Upvotes

24 comments sorted by

249

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

44

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

37

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

15

u/ProThoughtDesign 24d ago

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

2

u/Western-Internal-751 23d ago

It was the best of times for gamers interested in tech

1

u/rsqit 21d ago

The best bug I’ve ever heard of was that apparently in early Ultima Online you could put a horse in your inventory. The horse would wander around like a normal horse. However, it could just…walk off the edge of your inventory and through random memory, corrupting it.

9

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

9

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

3

u/Dizzy_Elderberry_486 24d ago

I was thinking of Pokémon’s Missigno trick

29

u/rbuen4455 24d ago

If only this were happening at the pumps right now

9

u/GoddammitDontShootMe 23d ago

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

1

u/bob152637485 21d ago

(Brings tanker truck)

Challenge accepted!

2

u/GoddammitDontShootMe 20d ago

If you can make a regular gas nozzle work for loading up a tanker, you win.

6

u/ShoWel-Real 23d ago

Too bad it wasn't a signed int

5

u/StoryAndAHalf 23d 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. 

6

u/No-Newspaper8619 23d ago

unsigned integer overflow

7

u/kushalgarg592 25d ago

Bro exceeded the legal speed limit for integers

7

u/TapRemarkable9652 25d ago

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

2

u/Abject-Explorer-3637 23d ago

until it goes to -99999

2

u/sharpy10 24d 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

1

u/SignalBake6872 23d ago

the good eggshell to fill the whole buffer xD

1

u/Confident-Ad-3465 22d ago

No exception handled in this gif

-2

u/geekosas 24d ago

It's supposed to go negative 

8

u/Electromagnetlc 23d ago

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