Maybe there's something wrong with the universe, but probably not
No kidding, I was just walking down a hallway in my building when I overhead the following quite loud conversational fragment through an open doorway:
Angry woman's voice: "Why are you in the ladies room?! You are the third man to... oh no."
Like Hobbes, it's the moment of dawning comprehension that I live for - the exact moment when she realized that she, not everyone else, was in the wrong room was readily apparent. (One wonders what the first two gentlemen did, since clearly they did not successfully disabuse the lady of her error.) Since the building across the courtyard from mine has a mirror-imaged layout, this is a very easy mistake to make if you are visiting from the other building.
I contrast that moment of dawning comprehension with Dr. Crusher's similar moment in that memorable 1990 episode of Star Trek: The Next Generation when she realizes that she's not crazy, it's the entire universe that is wrong. When faced with an absurd and unexpected situation - the gradual disappearance of first the crew and then the entire universe - she at least considers that she's the crazy one.
Unlike most people, I encounter compiler and library bugs all day long in my job, though mostly ones that I caused in the first place. (Sorry!) But even still, when I am writing "normal" code (rather than test cases designed to break the compiler or regress previous bugs), I try to ensure that my attitude upon encountering an unexpected situation is that I'm the crazy one. Usually it's my code that is wrong, or my misunderstanding the output, rather than a compiler or library bug.
As the authors of "The Pragmatic Programmer" point out in their third chapter, "select() isn't broken" - if you are writing perfectly normal code then odds are good you are not the first person to discover what should be an obvious problem in a well-tested product. If you think you've found a bug in the math library, maybe you have. Or maybe you've actually passed radians to a method that takes degrees, or forgotten to take floating point rounding error into account, or some other such thing. The more obvious the problem, the more likely it is that you're the crazy one. If the code doesn't compile and you think it should, it could be a bug in the compiler. But read the error message carefully; it is probably telling you what is wrong with the code.
If you think you've found a C# compiler bug, please, by all means bring it to our attention; post it on Connect, or have the community take a gander at it via StackOverflow or one of the Microsoft forums, and if you want, send me a link to the problem. (Please don't use the "contact" link to send me source code directly; the hostile-email sterilization code that filters that text is very aggressive about stripping out things that look potentially harmful. It makes code almost illegible.) There certainly are bugs in the compiler and the more we get good information on, the better. Including a small-but-complete program that reproduces the problem and the version number of the compiler you're using is a big help. But first, do stop and take a good hard look at the code and think about whether it is more likely to be a problem with the code or a problem with the compiler. Don't be one of those people who sends me angry, profane emails about a problem that you caused yourself; that's just embarrassing.
Comments
Anonymous
April 25, 2011
Ha ha! I laugh because I've was the exact same situation as that unfortunate woman when I was about 14 years old. In my case, the detective work necessary to figure out why there were no urinals in this particular "men's room" took just a few seconds longer than getting started. Once I had my moment dawning comprehension, I had a difficult decision to make...stop and make a walk of shame to the actual men's room or just finish out. To this day, I wonder what I would have done if a woman had walked in while I was there. On a more on topic note, it's nice to know that you also have moments where the system works correctly albeit contrary to your expectations. The systems I work on are significantly less complex than a compiler, but I can recall many times where the system has performed non-intuitive action and it takes a few of us a few minutes to realize its not a bug.Anonymous
April 25, 2011
The comment has been removedAnonymous
April 25, 2011
And this is precisely why I've started to insist first that the person claiming there's a bug justify his code. Once he demonstrates that he's using it correctly to do something reasonably within scope, and that what he's doing actually makes sense for what it is he's trying to solve, we can talk about whether there's a bug.Anonymous
April 25, 2011
I must say, the sentence about "the hostile-email sterilization code" made more sense when I misread it as "the hostile email-sterilization code". Why can't they get that right?Anonymous
April 25, 2011
When my program does something wrong, the mistake is nearly always mine, but there is one exception: stackoverflow.com/.../delegate-system-action-does-not-take-0-arguments-is-this-a-c-compiler-bug :)Anonymous
April 25, 2011
The comment has been removedAnonymous
April 25, 2011
The comment has been removedAnonymous
April 25, 2011
I find that using a "Cardboard programmer" to explain the nature of the bug usually solves the "problem". PS if anybody out there has an unwanted life sized Peter Norton cardboard cutout in good condition, give me a shout.Anonymous
April 25, 2011
Am I the only one that wants to see the particular email that spawned this post? Redact some personal information and stick it up! I've been seeing a number of "select isn't broken" posts on StackOverflow lately. And I've just been meaning to write this sort of thing for a while. Overhearing that unintentional situation comedy moment yesterday provided sufficient activation energy. -- EricAnonymous
April 25, 2011
The comment has been removedAnonymous
April 25, 2011
The comment has been removedAnonymous
April 25, 2011
You don't happen to know the name of that star trek episode, do you? You'll note that I put a convenient "hyperlink" to the Star Trek wiki. If you click on that link, you'll get information about the episode. -- EricAnonymous
April 25, 2011
I always start out by assuming that the problem is with me and not the compiler. It's usually a safe assumption, except for that one time when I actually did find a bug in the C# 4 compiler. The BadImageFormatException suggested very strange was afoot :). Thanks again for checking it out for me, and for your detailed explanation (it was the generic virtual iterator bug).Anonymous
April 25, 2011
@Erik: "Remember Me" (Star Trek: TNG, Episode 4x05)Anonymous
April 26, 2011
My experience tends to be "you're not the first person to try this, but the universe is indeed broken". I'll struggle with something for a little while and then STFW and find that a bunch of other people have run into exactly the same bug, sometimes years ago, with no fix in sight. :-(Anonymous
April 26, 2011
The comment has been removedAnonymous
April 26, 2011
The comment has been removedAnonymous
April 26, 2011
About 15 years ago, I had a guy working for me who wanted to call a company not named Microsoft every week because of a bug in their C compiler. Every time, he either misspelled something or forgot a closing brace in the C code. I was ready to take his phone from him.Anonymous
April 26, 2011
I agree that the compiler/library probably handles correct code correctly, and if the program doesn't work there is probably a problem with the code. But if incorrect code produces errors that don't indicate what is wrong with the code, I say the compiler/library also has a problem.Anonymous
April 26, 2011
I've found very few real bugs in the C# compiler, what I have run into more often is arbitrary limitations that are actually buried in the specification that conceptually shouldn't be there, which is what Microsoft I guess refers to as a "design feature". So the universe is normally accurate I guess but that doesn't necessarily make it right.Anonymous
April 26, 2011
The comment has been removedAnonymous
April 27, 2011
Kudos on the Trek reference. How 'bout an article on small API changes from version to version and compare it to the episode where Worf is shifting between parallel universes every time he comes in proximity of Geordi's visor?Anonymous
April 27, 2011
@Jonathan: generally speaking, good error detection and reporting is a good idea. The problem is that, at times, it can be too expensive, especially when most API clients are never going to hit the error case - yet pay the price for error checks. Sometimes it's a trade-off. VB throws on arithmetic overflow by default on all integral types - handy for detecting those pesky overflow bugs, but you get checks sprinkled throughout your code for every arithmetic op, most of which will never ever hit it in practice. C# does unchecked arithmetic by default, and you have to use /checked+ to enable that. Which one is preferable?Anonymous
April 28, 2011
@Pavel: Most of what I am complaining about is that when an error is reported, the information about what caused that error report is thrown away instead of being encoded into the error message. See these bug reports: connect.microsoft.com/.../system-badimageformatexception-is-not-informative connect.microsoft.com/.../typeloadexception-the-signature-is-incorrect-needs-more-information Due to Microsoft's refusals to fix these problems, and rediculous use of NotSupportedException in derived classes of Type related to generics and emitted types, I am writing my own library to replace System.Reflection.Emit. In another library that I provide, I use produce two versions, a developer version that does agressive error checking and gives informative error messages, and a release version that assumes the calling program is correct.Anonymous
May 02, 2011
Please address when VS 2008 will get SP2 given that SP1 was released Aug 2008 (over 2.5 years ago). Can we also get XP SP4 since SP3 was released May 2008 (3 years ago). It's important to us since getting a multi-man year effort approved to do a full retest of one of our larger systems is not possible. Our core systems each have from 200,000 to 750,000 lines of .NET code. You're asking the wrong guy; I know nothing whatsoever about service pack scheduling. And even if I did, which I emphasize I do not, I can't talk about schedules of unannounced releases. Sorry! -- EricAnonymous
May 06, 2011
@Bryan That post approaches theoretical maximums for nerdiness. I salute you, sir!Anonymous
May 06, 2011
@Ted It's pretty safe to assume: VS 2008 SP2: Never Windows XP SP4: Never Plannning on anything different is foolhardy at best.Anonymous
May 11, 2011
Interesting, the world sent you to tell me that I and not it is wrong. What is this world coming to?Anonymous
May 11, 2011
The comment has been removedAnonymous
May 26, 2011
The comment has been removedAnonymous
June 24, 2011
The comment has been removed