
A collection of debugging stories - luu
https://github.com/danluu/debugging-stories
======
jpatokal
Nice! Sent in a pull request to add mine:
[http://gyrovague.com/2015/07/29/crashes-only-on-
wednesdays/](http://gyrovague.com/2015/07/29/crashes-only-on-wednesdays/)

~~~
lordnacho
It happens quite often that bugs end up being obscure things like this.

The a-ha moment when you've figured one out is interesting. It's always a
mixture of pleasure at having discovered a complex causal chain and horror at
having written it.

------
kranner
A book-length, epic debugging story is in Ellen Ullman's novel The Bug:

[http://www.amazon.com/The-Bug-Novel-Ellen-
Ullman/dp/12500024...](http://www.amazon.com/The-Bug-Novel-Ellen-
Ullman/dp/1250002494)

~~~
101011
Another great read for debugging that was recommended to me years ago:

[http://www.amazon.com/Debugging-Indispensable-Software-
Hardw...](http://www.amazon.com/Debugging-Indispensable-Software-Hardware-
Problems/dp/0814474578)

------
egeozcan
Great collection!

Maybe one could ask the authors if they could donate their debugging articles
to a cc licensed repository so the articles themselves could be hosted instead
of linking? That would be very nice I think.

------
calhoun137
"This is the only time in my entire programming life that I've debugged a
problem caused by quantum mechanics." [1]

This quote is amazing lol

[1]
[http://www.gamasutra.com/blogs/DaveBaggett/20131031/203788/M...](http://www.gamasutra.com/blogs/DaveBaggett/20131031/203788/My_Hardest_Bug_Ever.php)

------
tfigment
Don't want to write a real post but my most memorable simple story was with a
C optimizing compiler. I was using a something like struct Item { char
name[12]; int flag; } with code that would would use this in a btree and use
memcmp(x,y,sizeof(Item)) for ordering. The name could be non-unique but
name+flag would be and give specific ordering. To fill Item I used something
like (much simplified):

    
    
      x = (Item*)malloc(sizeof(Item));
      memset(x->name, 0, 12); 
      strcpy(x->name, name);
      x->flag = flag;
    

So the bits after name are now significant in compares but expected to be zero
because of memset. Well the optimizer would effectively remove the memset in
release builds due to the strcpy so the code worked most of the time in
release but would occasionally break because the bytes after the null
terminated name could be anything and would only come into play when name was
the same for 2 items.

------
digi_owl
For some reason i love reading these kind of stories, especially when you get
the feel the writer is venting after a deep dive of the OS guts.

A close equivalent is reading Derek Lowe's "things i won't work with"
articles.

~~~
spaar
I absolutely loved the "Things I won't work with" articles, very enjoyable to
read. And I even learned some things about chemistry in the process. I can
only recommend everybody who is even slightly interested in chemistry to read
them.

~~~
wging
[http://pipeline.corante.com/archives/things_i_wont_work_with...](http://pipeline.corante.com/archives/things_i_wont_work_with/)

~~~
digi_owl
seems he has since moved to sciencemag, but i don't see any new articles in
that category over there (and all his old corante stuff has been copied over).

[http://blogs.sciencemag.org/pipeline/archives/category/thing...](http://blogs.sciencemag.org/pipeline/archives/category/things-
i-wont-work-with)

------
darasan
Sorry, but that first one:

[http://nanxiao.me/en/an-experience-of-fixing-a-memory-
corrup...](http://nanxiao.me/en/an-experience-of-fixing-a-memory-corruption-
bug/)

is really dumb. The moral is that you don't use global variables that are
accessed by multiple threads (unless you're very careful). That's C
programming 101.

------
yjgyhj
Great collection! Love these kinds of stories - hate to struggle with these
kinds of problems.

------
BtM909
No critism, but why would this be different than some of the contributions on
the daily wtf?

~~~
highwind
It's OK to have similar/duplicate things on the Internet. (It often is the
case.)

------
Sir_Cmpwn
Brought a smile to my face to see my story up there as #2 :)

