3 ms·
could swear I've had some debugging / system testing sessions where the effect of me looking into it changed its state :-)
by DyslexicAtheist 11y ago
could swear I've had some debugging / system testing sessions where the effect of me looking into it changed its state :-)
- rybosome 11y agoWe 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))
- knodi123 11y agoThis happens all the time. I very recently had an issue where a deadlock was fixed by a print statement, because two lists were being lazily evaluated at the same time, and the print statement forced one of the lists to be evaluated earlier and finished by the time the deadlock was occurring.