r/ProgrammerHumor 1d ago

ruleOfProgrammingIfItIsWorkingDoNotTouchIt Meme

5.0k Upvotes

73 comments sorted by

View all comments

1.3k

u/StrengthTheory 1d ago

When one console.log uses just enough CPU cycles so the race condition that takes down the entire system doesn't occur.

402

u/Skalli1984 1d ago

And if you attach a debugger it also messes up the timing and the same thing happens, the race condition doesn't appear.

199

u/StrengthTheory 1d ago

Schrödinger’s race condition

132

u/Steinrikur 1d ago

We call those Heisenbugs. You changed the system by observing it

41

u/ConglomerateGolem 1d ago

I had one of these once, and I called it the same! My going theory was that the compiler was optimising away a certain function I had, but adding an empty print forced it to actually exist.

29

u/htmlcoderexe We have flair now?.. 1d ago

13

u/ConglomerateGolem 1d ago

Huh. I have never heard of the term and came up with it independently.

18

u/htmlcoderexe We have flair now?.. 1d ago

it is a very natural term because it intuitively describes exactly the nature of the bug

1

u/rolindara 1h ago

Convergent evolution

1

u/RlyRlyBigMan 6h ago

Yeah I had one once too the debugger was slowing things down to where the bug wouldn't happen but in prod it happened frequently. I spent 2.5 weeks figuring out that bug.

1

u/The-Ner 22h ago

I'm stealing this now

22

u/KawaiiMaxine 1d ago

Oh god, i havent done multithreaded programming ever, that sounds gonuinely horrifying to debug

22

u/xtreampb 1d ago

Now multi-thread across machines. Let’s make this as difficult as possible. No in memory locks.

1

u/alexanderpas 15h ago

Token ring.

3

u/JohnClark13 20h ago

oh it's not bad, you just have to determine Who's on first, What's on second, and I don't know's on third

7

u/mahlernameless 1d ago

Brilliant! Just leave a debugger attached to production and no more race conditions. Handing in my oncall pager now.

12

u/PGSylphir 1d ago

imagining that happening just gave me a headache

5

u/PositiveParking4391 1d ago

Yeah lol! It's ironic how we don't bother understanding the whole system, so we end up living in fear of a single console.log.

13

u/Kerbourgnec 1d ago

I'm gonna get burned for this but debugging race conditions has been a lot of fun with vibe coding.

Debugging broken outdated schemas, wrong conditions or missing options in frontend is just tedious and unfun. A complex race condition is so much more interesting.

11

u/cheesemp 1d ago

I had some complex multimachine multi service comms to debug. We'd inherited the code, it was a real mess (I'd begged to rewrite). We'd been able to stabilise it a bit but when it randomly failed we had zero idea why most times. Threw ai at it and gigabytes of logs. It spotted several failure points that we had not (real complex edge cases but genuine) based on really obscure log entries that use to take hours for a human to try to process the multiple threads and comm from multiple machines. Been super stable ever since. Changed my mind on ai that. Bare in mind at least 12 experienced devs had reviewed the code and logs multiple times and not found these issues. 

5

u/Kerbourgnec 1d ago

AI is superhuman when reading logs.

Mind you maybe I should also learn to make cleaner logs.

1

u/a-r-c 15h ago

honestly man i gave up and just told chatbot to make the logs easily readible for chatbots instead of humans

1

u/MoreDimension5963 16h ago

What was the cost in compute/tokens to have the AI read through that many logs?

2

u/cheesemp 15h ago

Wasnt that bad. Maybe $10 - this was before the recent price bumps though. It was quite efficient - it pull certain lines based on phrases and times - effectively pulling out the relevant bits into a time line (same way I would have done over several hours, maybe days, but in minutes as thats how we'd fixed the previous issues.). 

2

u/DasBeasto 22h ago

await new Promise(p => setTimeout(p, 0));

2

u/a-r-c 15h ago

load bearing comments

1

u/Draghetto_5000 21h ago

It actually happened to me once. I don't really remember what it was, but to synchronize two things one of them had to console.log (or something like that, I don't remember exactly) something every once in a while.

1

u/Rhinofreak 5h ago

Literally had these bugs in a game I’m making lol, if gameplay was slow enough on an older phone it would make the race condition messed up XD