WishUnderflow
WishUnderflow
WishUnderflow
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.
If there's parallelism/async involved, then there definitely is an argument to decrement first, execute later. Otherwise you could make a wish for the genie to just wait for an hour and then make as many wishes as you want within that hour.
What if one of the threads crashes while executing the wish? I demand warranty!
But how can you decrement a future dated wish, since you can't guarantee nothing will happen that prevents the genies ability from executing said wish? E.g. i mean like telling the Genie to do something 5 days from now, not your example which would begin immediately after making said wish.
I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place.
Why? Shouldn't you decrement the limited resource the user has access to in case the thing you are doing fails?
You’d need a check to make sure they don’t wish for something not allowed (like more wishes).
Genie: these wishes are of type signed int64. you now have -1 wishes. you owe me a wish; i wish to be free.
Then you find out the genie uses a signed data value and you now owe him a wish. You're not granted magic. You're compelled to grant the wish. The only restrictions on the genie's wish is that it must be within your (soft, squishy) mortal power.
I can imagine you being reset to the point of the genie's wish every time you die (naturally or otherwise) without succeeding. This could well turn into a Groundhog Day type situation.
Ooh I would gladly avenge everyone who had wishes before me by being very maliciously compliant.
Every wish you grant causes you to owe more wishes to the genie
Wouldn't it depend on the order of operations, you'd think even vibe coding a genie would still have the sense to lower the counter before granting the wish.
So logically
Wishes = 3
Make wish count zero.
*wish used, wish count 2
Wish applied, wish count 0
It seems logical to decrement after the wish is granted, imo. Just causes issues in this particular case...
Dunno, I know enough duplicate exploits in games to know giving the effect then reducing the item, is a pretty common source of duplication hacks/bugs.
I guess it comes down to which is the designer is more afraid of happening, the chance of a wish being expended but not granted, or granted without expending.
Then again based on disney's aladin, tricking the genie into rescuing him without using a wish, it does seem practical to assume that the genie errors on the side of granting without expending.
Me: I wish you to tell me truthfully, exactly how many wishes I have remaining.
Genie: crashes
Now make it 2.5 wishes. Now 0.9. Now 999.
Found the QA tester.
Genie API times out due to detected fuzzing
After you made it 0.9 you no longer have enough wishes left.
"Subtract 4 wishes"
Not a computer scientist but (regarding the post title), this is still classified as an integer overflow as the result -1 flows out of the domain your datatype can represent (0-255).
\
An integer underflow is when two numbers are so close to each other they become indistinct in your representation. For example a number that is so small, a float would represent it as 0.
\
Love the meme though :)
Righto Gandhi, put the nukes away
Id they were optimized to use unsignrd they would be optimized to use 2 bits for 3 wishes rather than 8. You have 3 wishes left.
Should've been "make -1 wishes" 0 is 0
Edit:oh I get it. First the gene fullfill the wish then subtract one from the 0 wishes.
I'd like yo have '); DROP TABLE Wishes
wishes
You fool, you've unleashed ghandi's thermonuclear rage!
wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?
You're correct but you have an off by 1 error.
First, the genie grants the wish.
NumWishes=0;
Then, having completed the wish, the genie deducts that wish from the remaining wishes.
NumWishes--;
And to complete the thought,
Lastly, the genie checks if the lampholder is out of wishes
If(NumWishes==0) {...}
(255==0) evaluates to False, so we fall past that check.
Yeah, but what if the counter gets decremented before the wish gets granted, huh?
This is actually genius
Genie reduced number of wishes to 0. But by doing so he granted one of the wishes, so it became -1 (255).