4 ms·
We call those "heisenbugs" - one of the most terrifying and maddening things you can encounter prior to a launch. I'm almost positive that I remember reading a
by rybosome 11y ago
We call those "heisenbugs" - one of the most terrifying and maddening things you can encounter prior to a launch. I'm almost positive that I remember reading a sort from a game dev who ran into one of these right before a release, where printing some variable caused it to have the correct value; in this case, it was left in the game.
- EwanG 11y agoWell, I know that I ran into a situation (and may once have posted about it) in a C program where I was doing printf to debug a program, and it ran fine. Whenever I removed them, the program would crash. Finally discovered that the printf debugging was forcing garbage collection which took care of a bad pointer somewhere else in the program. Honestly can't remember if I ever found the pointer or just left the printfs in the code...
- nitrogen 11y agoThank goodness we have Valgrind these days. Though I don't know how well it would handle a C app with a garbage collector. Calling printf can (will) change what's beyond the stack of the calling function, so if the pointer in question pointed outside the active stack, printf may have put a safer value there by coincidence.
- backlava 11y agoThere's the related example of the segfault termination message that was changed in a hex editor to "thank you for playing!" Wing Commander, maybe.
- knodi123 11y agoThat's a classic!
- justifier 11y agoany language with mutable values will drive an unwarned mind insane methods of disassociating mutable objects before printing will save you from some heisenbugs a la javascript console.log(JSON.parse(JSON.stringify(obj))