Live data from Hacker News

Heisenbug

en.wikipedia.org

21–30 of 34 posts

Re: Heisenbug

#22
post #8
post #4

Earlier quoted context omitted.

Probably 'bug' is not the best word, but many programmers definitely consider excessive complexity as 'bad design' (unless complexity is inherently unavoidable due to the very nature of the problem).

And others pile it on in the name of "user friendliness" or "security"...

User friendliness and security are not the parts that are bad. "Piling them on" is the part that's bad. UX and security need to be considered from day one.

Re: Heisenbug

#23
post #9

If you hate heisenbugs, use Functional Programming (or data-race-safe langs such as Rust). It will kill 99.99% of them.

That's assuming that heisenbugs are caused by concurrent programming alone. But a ton of heisenbugs happen in boring single-threaded programs.

Re: Heisenbug

#24
post #15

One of the first heisenbugs I encountered was IE8's console.log. That object/function was only defined when the developer tools were open. Otherwise you would get an exception (but of course you couldn't see that exception in any place). Daily effect was funny: When you forgot a console.log in your code your page JS would hang. When you tried to debug it by opening the developer tools everything worked- and you start…

But... how on earth did that escape QA? I mean surely even whoever was developing IE8's developer tools would have had accidentally forgotten a console.log() or two during development, surely?

You have to be mindful of the fact that IE8 was the first IE to have console.log[0] and that as a result it is possible that it wasn't used by the developers. It's also possible they always had the console open during development.

How did this ever manifest itself? The only thing that seems a plausible explanation is that the console injects the console object or the console.log function into the global JavaScript scope when it is opened and according to the behaviour described and either garbage collected or removed from scope when the console was closed. This seems like it could have only really been the intended behaviour.

[0] https://developer.mozilla.org/en-US/docs/Web/API/Console/log...

Re: Heisenbug

#26
post #9

If you hate heisenbugs, use Functional Programming (or data-race-safe langs such as Rust). It will kill 99.99% of them.

That's assuming that heisenbugs are caused by concurrent programming alone. But a ton of heisenbugs happen in boring single-threaded programs.

Tons? In my entire career I haven't found one of those.

Re: Heisenbug

#27
I transitioned over from hardware design long ago. We had a similar concept where the circuit would work, but only when an oscilloscope probe is attached at the right place..

Re: Heisenbug

#29
post #26

Earlier quoted context omitted.

That's assuming that heisenbugs are caused by concurrent programming alone. But a ton of heisenbugs happen in boring single-threaded programs.

Tons? In my entire career I haven't found one of those.

Any programming language with pointers such as C or c++ where you can have wild pointers, use after free etc can be a breeding ground or hisenbugs. Consider yourself lucky.

Re: Heisenbug

#30

One of the first heisenbugs I encountered was IE8's console.log. That object/function was only defined when the developer tools were open. Otherwise you would get an exception (but of course you couldn't see that exception in any place). Daily effect was funny: When you forgot a console.log in your code your page JS would hang. When you tried to debug it by opening the developer tools everything worked- and you start…

This is one of my "favorite". I often remind junior developers who just started coding in the last few years about stuff like this since a lot of our client's still insist on IE8 support (thankfully not IE 6 or 7 anymore).

Another fun one was dangling commas in arrays, which breaks IE 7 and lower.

It used to be somewhat common to put something like this at the top of scripts:

if ( window.console == undefined ) { window.console = { log: function() { }; }

Post reply on HN