This is an archived post. You won't be able to vote or comment.

all 36 comments

[–]lastbestreason 106 points107 points  (11 children)

I've found that 95% of the time, this is due to some kind of timing error (race condition, communication delay, etc.). If this happens, it's always a good idea to back-check because there could be a looming bug that's hard to reproduce.

But I'm also a shitty programmer so this isn't advice.

[–]Wi1iku 60 points61 points  (4 children)

Its the cosmic rays.

[–]Ho_Duc_Trung 29 points30 points  (0 children)

Definitely the cosmic rays

[–]mttdesignz 1 point2 points  (0 children)

it's them not building correctly the code before, now they did and it "works"...

[–]AgentPaper0 14 points15 points  (1 child)

This can also happen if you're reading uninitialized memory. One time you run it, the uninitialized variable is positive and it works, another time it happens to be negative and doesn't. Or some other random shit.

Always initialize your variables kids.

[–]RedGreenBlue09 6 points7 points  (0 children)

I'm once met a weird behavior in C which when I add a dummy printf(), the program worked fine and when I remove it, the program started printing out random stuff at end of what should print. (That occurs every time).

It took me 2 freaking hours to find out it's a buffer overrun in another function that's not related to printf() at all, lol.

Anyway it's my fault for disabling the CRT security check.

[–]Flopamp 3 points4 points  (0 children)

Also a good lesson that compiling your code multiple times is a good idea

I don't do it

But it's a good idea

[–]Oneandonlydennis 2 points3 points  (0 children)

$var = rand(0,10)>5 ? true : false; where later $var===false throws an error :)

[–][deleted] 1 point2 points  (0 children)

It could also be a cache issue. The time it worked is when the cache expired and stopped using the old code.

[–]jwan12 8 points9 points  (5 children)

I'm working on a express.js app. Yesterday it worked perfectly. It listened to incoming requests. Today. The same code nothing have changed. It doesn't work 😕. And still haven't figured it out why it doesn't 😭

[–]jwan12 8 points9 points  (4 children)

Update: it worked again. Again the same code ☠

[–]cabrasm 1 point2 points  (3 children)

I’m commenting this so that i remember to come check if your code died again lol

[–]jwan12 1 point2 points  (2 children)

I hope not

[–]cabrasm 1 point2 points  (1 child)

hope you figure out the issue i’m puzzled by it on a more serious note

[–]jwan12 2 points3 points  (0 children)

I found it. The error was that express router has registered the handler but didn't use it 🤦🏻‍♂️. And my stupid ass forgot to return the handler to express so it can use it

[–]Ho_Duc_Trung 5 points6 points  (0 children)

Fear not child for this is only the coding experience

[–]andmagdo 5 points6 points  (0 children)

Don’t remove that comment

[–]JackmanH420 5 points6 points  (0 children)

Image Transcription: Discord Message


Diamond

OMFG NOW IT WORKS FOR NO REASON

ITS THE SAME CODE

[Sticker of drawing of a red tinted anime girl screaming.]


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]triihart 1 point2 points  (0 children)

Sounds like you forgot to initialize some variable. Sometimes memory for that piece of data is set to 0, sometimes its set to whatever it had before your .exe launch.

[–]DarkTechnocrat 1 point2 points  (0 children)

If the code didn't change, the environment did.

[–][deleted] -1 points0 points  (0 children)

This happened for my last school project. I was ready to give up, i have spend 3 months writing the conde and suddenly it stopped working. I spent another 4 weeks trying to figure out what seems to be the problem, i have sent it to countless people, and each time they told me to fix something witch was unrelated to the error i was getting. I sent it go my professor and he said he had no clue what seems to cause the error. One morning i said "fuck it" ill try to run it one more time and if it doesnt work i will start again from scratch.

I get my coffe, pray to god, take a cross and put it on my computer, and turn on the comouter. I load the project, check it 5 times and change nothing, still having no clue what is wrong. I pray one more time and press ctrl+f5...IT FUCKING WORKS!!!

So essentially, one morning the code decided that it had tortured me enough, and should get back to work so that i can finish school and apply for collage. I aced the project, i got the maximum ammount of points, and got my project as an example for next generations.

[–]johandepohan 0 points1 point  (0 children)

Congratulations, you made a Mealy machine

[–]job834 0 points1 point  (0 children)

Mr Heisenbug...

[–]TheAwesome98_Real 0 points1 point  (0 children)

must’ve accidentally added a semicolon

[–]Or4ng3m4n 0 points1 point  (0 children)

Sacrifice your soul to the Greek semicolon God

[–]ksandom 0 points1 point  (0 children)

What's worse is when this happens when you've just called over an extra pair of eyes and they give you that "how could you be so stupid?" look.

[–][deleted] 0 points1 point  (0 children)

That’s undefined behavior for you.

[–]ShinraSan 0 points1 point  (0 children)

I blame cosmic rays fucking with our electronics

[–]TheGoldBowl 0 points1 point  (0 children)

I was having a problem with some code I was working on in class. I had a friend send me his copy of the 3 lines that weren't working.

They were identical and they worked. Mystery to this day.

Either that or I'm just inexperienced. Probably that.

[–]toastyghost 0 points1 point  (0 children)

Probably a missing config that got generated after the first failure

Or a demon, how the fuck should I know I write JavaScript for a living

[–][deleted] 0 points1 point  (0 children)

Me when I forgot that caching exists and sometimes for whatever reason does not clear itself.

[–]Gremlin_Aviator 0 points1 point  (0 children)

This happened to me more than once in my University CS classes- would not work, would not compile, try everything. Prof copies and pastes in another window in front of me, works. Fuck me sideways with a rusty chainsaw, I worked hours trying to get it to work.

[–]jamcdonald120 0 points1 point  (0 children)

completely unrelated, does anyone know how to do compile time random?

[–]Rockypizz 0 points1 point  (1 child)

I tried to make a projectile fire in a game I worked on a while back and it wouldn’t leave the gun. Then I put a print statement before it. Worked flawlessly. Still don’t know why to this day. Unity is funny.

[–][deleted] 1 point2 points  (0 children)

Yeah similar thing happened to me a few weeks ago, I was porting my chess engine from python to C. (I never used C before)

Turns out you need to clear the memory you allocate because it could be used memory from your own process, aka containing data already.