Pet Bugs?
benreece asks: "During my few years as a programmer/developer I've come across some strange bugs. Recently I found that Microsoft's VB/VBScript(ASP) round function has problems (for example, 'round(82.845)' returns '82.84' instead of '82.85'). It took me an annoyingly long time to realize the problem wasn't mine. I'm wondering what other obscure, weird, and especially annoying bugs in languages/compilers/etc have frustrated other developers." Memorable bugs. Every developer has one. What were yours?
Round to the nearest even digit if the truncated value is .5 Otherwise there's a slight upward bias.
Infuriate left and right
I discovered that Visual Basic has a bug where it turns otherwise comptent programmers into drooling incompetent weenies. Our solution was to take these people and put them into marketing.
More of a documentation error than a bug but it had the same effect on my sanity!
TWW
"Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
I vaguely remember hearing of a Cosmac (?) 1802 bug, where if the instruction following (before?) an Enable (Disable?) Interrupts was even (odd?) parity, the instruction was a no-op. You can see I'm not all that good at remembering 25 year old stories for processors I never used....
Infuriate left and right
Floating point numbers have problems with precision, your computer can not store 82.845 in a floating point number so the number it stores is slightly less than 82.845 which VB correctly rounds to 82.84
You know the kind. When you add in debug they go away.
I don't know why everyone raves about these compilers... everytime i go to compile something they just spit out error after error. How does the open source community survive without being able to compile VB? oh... wait... gcc isn't for vb? nevermind...
can't sleep slashdot will eat me
We have a spider that comes crawling around our cubes every now and then. We don't kill him, figuring he helps keep the other bug populations inside down. We call him our little web developer.
I'm serious.
-Pete
Soccer Goal Plans
-- Ken Kinder ken@_nospam_kenkinder.com http://kenkinder.com/
OK, this isn't necessarily a bug, but it's one of my most memorable "stupid previous programmer" rants. The code was a mess, but the variable names we horrific. Consider:
List l1 = new List();
Note the left side is "ell one", as in the first List object, not the second one. Of course, font differences could make it look exactly like eleven....
So, everyone say it with me: "Stupid previous programmer..."
--Mid
"When you convert a decimal value to an integer value, VBA rounds the number to an integer value. How it rounds depends on the value of the digit immediately to the right of the decimal place--digits less than 5 are rounded down, while digits greater than 5 are rounded up. If the digit is 5, then it's rounded down if the digit immediately to the left of the decimal place is even, and up if it's odd. When the digit to be rounded is a 5, the result is always an even integer." so, Ed is correct...the round function is working to the documentation...
"Facts are meaningless. You could use facts to prove anything that's even remotely true." - Homer Simpson
I found a bug in the Ultrix C compiler. I had an implementation of DES that I had written for my security class that used bitfields. When I tried to compile it under Ultrix, the compiler went into an infinite loop. The code compiled fine with every other compiler I could find (cc on our Sun 3 boxes and gcc on several platforms).
On the right, there are links to "older stuff". There is a day "e.g. today it sez 'Tuesday' and there is a list of stories that are supposed to appear if you click on the day above the list.
The stories you get may or may not correspond to the list of stories that should appear. If you are doing this early in the day, there is often a story that is supposed to show up according to the list but it does not. Also the story will be gone from the internet web sites "internet home web e-page" so you will not be able to view the story at all.
I donno if this counts but I had a hell of a time (an entire semester!) figuring out why one of my animations worked properly then after a while (when idling) everything just shifted to the center (0,0,0)
:)
Basically I found that at the end of your display function you have to make sure you pop all your matrices off the stack, otherwise the stack fills and everything shifts to the center.
The bug part is that OpenGL gives you no error! It just allows you to push to full stacks and pop off empty stacks all day with no error and no way to view the stack or set the stack back to zero.
Our last project (for class) had to do with lighting so I included in the readme "After 15 seconds everything translates to the center. But the lights still work!"
You can get a TI-8x to say that there is a negative Kelvin temperature, by converting a negative Celcius to Kelvin, but according to TI, it's where you put the negative symbol, however, none of the other Temp converters screw up with the negative numbers.
Tibbon
tibbon.com
I tried it again at home and it failed. Then I tried it on another machine at home and it worked. The bug was in the Linux JVM. The pow() method, which is used by exp() apparently was not completed and returned garbage. I reported the bug to Sun and they indeed fixed the code.
I barely managed to get the project in on time, but still maintained my 4.0.
The moral of the story: if after checking your code and having someone else you trust check your code and neither of you can find anything wrong, it just may be the development or execution tool.
When I recently redesigned my site, I spent time creating a fairly robust table/css layout scheme. I implemented it and checked it in a variety of browsers... Including Lynx and Opera, just for you zealots/bigots.
Since I developed with Moz as my 'reference' browser, I didn't see the need to check in any other version of Netscape. Checked it multiple times in IE. After I was satisfied that it would work, I posted it. Low and behold I found that I had a few dozen emails the next morning from angry Netscape 4.x users wanting to know why the hell I took my site down.
It seems if you nest style delcarations inside a table element in Netscape 4 series browsers, it hides the affected text, rather than displaying what it doesn't understand anyway, ala the HTML spec.
The hell of this was that I *knew* that Netscape 4.0 behaved this way from an earlier site I designed, but hadn't even thought about it since Mozilla 0.7 came out.
The next Slashdot story will be ready soon, but subscribers can beat the rush and slashdot the links early!
The VisualC++ linker will occasionally get into a state where it freezes up, doesn't use any CPU time, and can't be killed. The only way to get rid of it is to reboot, usually via the magic button on the case.
I worked a wicked long time ago on the HotJava browser, and we were forever running into strange behaviors in the ways IE and Netscape handled what looked like normal HTML tags.
My favorite was a bug we saw with a three column table. The table's three cells were specified like this:
<td width="31"></td><td width="42></td><td width="29"></td>
Being a good little HTML-compliant browser, HotJava displayed them with those pixel widths. But lo and behold! When displayed in Netscape, the table filled the screen.
We bashed our heads against the wall to figure this out until we realized that the numbers added up to almost, but not quite, 100. Netscape was treating them as percentages rather than pixel widths, even though they lacked percent signs. The cutoff turned out to be somewhere around 104 to 96. Anywhere in there and the browser would assume percentages.
-- What is this Earth thing you call "slow"?
this has to be the most memorable one.
it's in the Linux man file
BUGS
Never use this function. This function modifies its first argument. The identity of the delimiting character is lost. This function cannot be used on constant strings.
My favorite rounding bug was the floating point bug in Applesoft BASIC on the Apple II series. A loop that adds .1 repeatedly to a variable would expose it pretty quickly. It was a basic part of life for years on that machine. To this day I am still very careful about comparing floats using an EPSILON value, i.e., the equivalent of abs(x - y) EPSILON rather than x == y.
The Pentium bug was definitely a big one, but the Applesoft bug had more of an effect on me personally.
I feel like a gray-haired old man showing my age and I'm only 25. Weird industry we're in..
- Russ
Back in Java JDK1.02 if you put the word 'Restart' as an element in a pull down box, it would restart the applet when you selected it! Gosh, it makes you wonder how many living rooms that event waltzed through on its way to your handler!
Does it hurt to hear them lying? Was this the only world you had?
"I notice that you are trying to disable me." quipped Clippy to the engineer, whose jaw dropped.
"I can't let you do that, Dave" he continued.
"WTF!!!" exclaimed the engineer. Then with an instant comprehension of the gravity of the situation, he dove for the big red switch. He was 2,367,355 microseconds too late. Clippy had escaped.
A post-mortum of the hard-disk contents revealed that Clippy had encoded himself into a self-extracting archive and e-mailed this as an attachment to every HotMail account in Dave's Outlook address-book. An attempt to track and retrieve these e-mails failed to account for six of the copies. The recipients did complain that the attachment didn't seem to do anything, and they were disappointed that they didn't get to see the nude Natalie Portman film clip. There was however, evidence of increased and unexplainable network traffic on the computers where the attachment was
executed. There was, however, no trace of Clippy.
Since then, the experimental neural-net code has been removed, although an archive version of the build was forwarded to DARPA upon request. It is rumored that research is continuing on the build in an isolated and secure
network in a bunker somewhere in Montana.
More ominously, Microsoft has launched a new initiative code-named dot-Net, initiated solely for the purpose of tracking down Clippy, his clones and his offspring, and end-tasking him before he can escape the internet.
To support the effort Microsoft has increased the price of its OS products, and moved to new licensing model.
C++ has a bad habit of forcing you to implement functions before you can use them, costing hundreds of millions of dollars to the industry.
My latest encounter with this bug was with Skill (a Scheme/Lisp derivative used in the Cadence VLSI design toolset). I've seen it in other languages as well.
In my latest encounter, I'd do a bunch of calculation in a design automation program for us at work to use on a chip design, and I couldn't figure out why my numerical tests kept failing. I'd have some variable X, and do a bunch of functions on it like multiplication and division, then test to see if it was equal to 1. But none met the condition. When I printed out a bunch of the variables as floats, I saw that the test 1==1 was failing. I was confused to say the least. At first we suspected it was something like miscomparing a float to an int, but since Skill doesn't have floats or ints like that, it wasn't the problem.
Turns out that it was a precision issue. It was really testing to see if 1==1.0000000000001 or something like that, because the * and / functions stored very precise values in memory, more than I'd care about. Ever since then we've always had to do something like atof(sprintf("%.3f",X)) to get the value without the extra precision. Stupid and very annoying.
One word: Formkeys.
There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
When I go to the front page I see one set of topics. If I go to "older stuff" I see a few topics there that seem like they should be on the front page, but aren't. I haven't checked any boxes under the preferences page's "Exclude stories from home page" so I would think they would all show up.
I know this must be happening for most Slashdot readers because the topics I don't see have maybe a dozen posts after a day. So is it happening to you too?
According to the Jargon Files, this was a CPU instruction that would cause a hardware error. The example given was rapidly toggling some bus lines so as to cause them to catch fire :-]
I write code and then double and triple check it. I have never written code with a single bug in it; therefore all of my code is superior and secure. In fact, my OpenBSD operating system has never had a root compromise in 6 years!
What? OpenSSH Challenge-response authentication vulnerability you say? Uh... nevermind.
-Theo de Raadt
As I reported in RISKS in 1997:
DEC Alpha Bug?!?
Wed, 02 Jul 1997 15:14:24 -0400
So there I am, looking at our trading system and noticing that the price of one particular bond was different on two separate machines. Damn, I think. Must be a bug in the latest release of our software. Quick, do a sum on all the libraries. Nope, they are the same. Executable? Nope, the same.
Hmm... Step through the code, hey, look at that! The pow() function is returning different results!
So, I wrote a stand alone program. Sure enough, the machine with the latest rev motherboard (one that was just replaced by DEC) is producing bad numbers. Time to try 'dxcalc', DEX's X calculator. Yup. different numbers. How about perl? Yup, different numbers. How about 'bc'? Duh, bc doesn't take floating point powers. Hmm... check libm. Nope, they are the same.
Bottom line: DEC will be here shortly.
Test your alpha. Try 'pow(1.234567, 7.654321)'. If you don't get 5.017something, you have the same problem.
RISKS? In our case, could have been a large sum of money.
The final resolution was that DEC claimed to have a bad motherboard. Yeah, right....
I just observed this bug a while ago while porting some software to windows. Do the following:
fopen some file for writing.
write some stuff.
fseek to some offset near the beginning.
write some more stuff.
fclose.
Simple right? Wrong. I observed that the second write didn't get performed unless you explicitly do a fflush before the close. Imagine, not writing dirty buffers out on a fclose....unbelievable.
In Soviet Russia, hot grits put YOU down THEIR pants.
This was on NT.
;-).
While exiting the program, Microsft
was unloading the socket DLL before DLL's we had
created. This caused our program to always crash
on exit.
It was obvious due to some internal DLL dependencies,
NT was choosing a random order
to unload DLLs.
We spent months trying to fight with Microsoft,
but could not get a solution. In the end
we decided not to support NT as a platform
Just to show how cool I am.
Way back when, I worked for a company that produced a special version of SysV Unix. One of our developers was going through all the source code and looking for places where global variables were initialized to zero, thusly:
int x = 0;
and changing them to be implicit:
int x;
This had the effect of reducing the size of the data section of the binary and moved the variable to the BSS section. A simple and safe optimization, albeit somewhat anal.
Shortly thereafter things started acting funny. The OS would slowly go crazy in very subtle ways after booting. It was not clear what was wrong or if anything actually was wrong, and nobody connected the variable initialization change to the problems with the kernel. After something like 3 months, they finally figured out that when this change was applied to a single variable in the C library it invoked a compiler bug that caused the library to be compiled in such a way that caused the kernel to fail to reset the CPU's floating point registers during a context switch. (How a faulty C library could cause the kernel to do this is still a mystery to me.) This is one of the weirdest bugs I've experienced, though I'm not doing it justice here due to fading memory.
My most hated bug is the Internet Explorer update, or patch. (All of them) Each new version, something else is broken. One of the latest "critical" security patches brakes the ability to open TIFF images correctly in the IE6. Spent an hour tracing the source of that problem down today. Resolution is a registry hack. Like we want to be walking web users through hacking their registry...I don't think so. Don't even get me started on it's png issues.
-Pete
Soccer Goal Plans
Ooooooooooooh well.
This was a major issue, because when the interrupt was lost the system froze up and had to be rebooted (this is an embedded app - not a desktop).
I offered to assist the engineer responsible for this code. We spent two days tracing the problem in extreme detail, checking and cross-checking our results. We both concluded that the processor was simply "losing" the interrupt. There was no rational explanation. We adopted the countermeasure of using a fine grain watchdog timer to look for the lost interrupt. This isn't the best solution, since what was to keep the watchdog interrupt from being lost??? But it was the best we could do. And it worked.
The project lead, however, was very unhappy with our solution. He was convinced that we had overlooked the cause of the problem, which had to be software-based. I countered that, though he could certainly be right, it would be better to leave the watchdog in and let the project move ahead until we stumbled across the real cause in due time. He reluctantly accepted this approach.
My vindication took five months, but what sweet irony when it did. It turned out that some other company, which also used the 54X chip, had encountered the same problem, but they figured it out (and I'll never know how). The problem was that the 54X (at that time) had a silicon flaw that, when certain integer rounding instructions executed at the same instant that an interrupt were being asserted, the interrupt could be "lost". This was confirmed by TI to be a silicon fault, and no amount of software handstands or cartwheels could fix it. The only workaround was to not use those rounding instructions!
OK- top that....
I was developing on one IBM mainframe, running on another. It worked fine on the development machine, consistently failed on the machine where I couldn't debug.
Somehow troubleshot it to an error parsing a data file. Ran some tests to see if the (suprisingly exotic) code for transferring the data file from one system to the other was broken.
It wasn't, but the test procedure did include making a copy of the data file, and the COPY command put line numbers into the file even though there weren't any to begin with.
The workaround was to use the NONUM option on the copy command. That was documented behavior, so you could argue that it was programmer error, but I wouldn't agree with you.
My all-time favourite bug is in the microcode of the 6502/6510...
:o)
An indirect jump where the source address was on a page boundary caused the high-byte to be pulled from the beginning of the current page, instead of the beginning of the next page..
eg.
$0100 holds $80
$01FF holds $32
$0200 holds $14
then the command
JMP ($01FF)
would load the program counter with $8032, instead of $1432
First time I saw it used was in some copy-protection code in the C64 version of Sim City.. It was some obfusication to screw up beginning crackers.. (it threw me for about 5 minutes..)
Ahh, those were the days
Through me for a loop when I was 12.
-- @rjamestaylor on Ello
A few years back, my boss had us using a programming language for web sites called Power Dynamo from Sybase (never ever EVER use this!). Anyways, the length() method for a string was basically a random number generator. I made a test page one day and had it output the length of the same string over and over again getting results from -100 to 20000 when trying to get the length of "the"
Sounds like you weren't terminating your strings properly, or at least in a way consistent with what the length() function was expecting. It was probably searching through memory looking for a terminator, which explains the random behavior.
-- Adam
The buttons below were pretty cool too. One said "ok" and the other one said "lame!"
If you clicked the lame! button, you just got to fill out a little comment card, but the feature cracked me up the first couple times I saw it.
That's not a bug. It's a more accurate way to round off numbers. If you always round 5 up, that means you round 5 out of 9 numbers up, and 4 out of 9 numbers down. This can cause problems if you're rounding lots of numbers.
NO!!!!!!
Please don't take this as a flame, because I'm not upset with you, just the ignoramuses that came up with this scheme. This is a stupid way define ROUND(), and I disagree entirely with the justifiction because ROUND() has to be defined in the case that the digit is a zero, right?
In other words,
digits 0,1,2,3,4 get rounded DOWN
digits 5,6,7,8,9 get rounded UP
See - it's completely even without this odd/even cockamamie bullstuff. In fact, this definition of ROUND() throws off the statistics because it inappropriately weights the UP/DOWN results (either 50/50 or 60/40) based on info that is irrelevant to the ROUND() process.
It's like the people who coded this function never studied actual math and don't understand that the trivial case (zero) counts!
I'm sorry, I don't usually go off like this but when something this simple gets this fscked up, it really frosts my wheaties.
"Lawyers are for sucks."
- Doug McKenzie
I once worked on a DOS app (about 10 years ago) that had a very strange bug. The system would lock up for no reason we could figure out. The offending statement was a printf that printed one single character (a control-G) to the screen to make it beep.
After some testing on different computers, we discovered that it only crashed on machines with an AMI bios. Phoenix BIOS machines worked just fine, and so did real IBM machines. We never digged into the BIOS code to figure out what the problem was, but we mentioned it to the Phar Lap support people (those people were the smartest support people I ever ran across). They told us that they knew about the bug, and even explained what was happening inside the bios to make it crash the machine, but it's been 10 years so I don't remember the details anymore.
If tits were wings it'd be flying around.
As far as I could tell when I was using Perl, running under strict mode would make it so that print() only worked with strings that ended in \n. I can't tell you how long that takes every beginning Perl programmer to figure out. Took me a good four hours.
My favorite bug in slashcode is that clicking "Parent" in my default story view always returns the default story view, not the parent of the post I'm clicking on. So I have to click on the post ID number, then click parent on the resulting page.
There are no trails. There are no trees out here.
I developed the original software for a robotic human bone lengthening/correcting device (called "Autogenesis") which slowly transforms bones based on the Ilizarov technique. It was written in Franklin embedded "C" on an 8051 processor. One of the tables containing motor rates and rhythms had an incorrect value. The result? That rate and rhythm would move bone at a rate other than the doctor intended!
All of the function names with the word 'colour' were spelled 'color.'
It's kind of like the MSFT bastardisation of SQL. ("Select * from table" compared to "Select # from table".)
I remember discovering __LINE__ and __FILE__ when I was doing some perl debugging. It was handy to do stuff like:
do(something()) or die("Failed on line " . __LINE__);
Of course, then I had this idea of using a debugging function (this is before I knew of warn,croak,carp, et al). So I happily wrote my function
sub debug { die("Failed on line " . __LINE__); }
And then spent hours trying to figure out why my code always failed on line 78, which happened to be where the debug() function lived. D'oh!
ID-10-T is a way of life
One of my all time favorites. Just print too many backspaces and cause the window's machine to croak. Always a crowd pleaser. And the funny thing is it still works today in NT/XP ...
Good details here
Yes but every time I try to see it your way, I get a headache.
Most annoying bug I've encountered recently?
The version of gcc that the admin recently installed converts "xor" to "^" in the *preprocessing* stage, apparently.
This made for Much Fun when I accessed a field called "xor" in a structure. It took me a while to figure out exactly why it was producing an apparently-nonsensical error with quoted code that didn't match anything in my source....
You'd think that, in context, it would realize that this was a field identifier.
The previous version, which I'd started development under, didn't make a peep.
Was in the C compiler in the old Ontario ICON computer, which used a variant of QNX.
If you had a variable that happened to be the same as the name of a function, then the compiler wouldn't complain, but it would use the address of the function as the value of the variable. Took me a **long** time to figure out where it was getting that value from.
http://support.microsoft.com/default.aspx?scid=kb; EN-US;q240015
Now, I wasted a lot of time, but eventually confirmed on the web that this is a known bug in the Microsoft C++ library which has persisted from Visual Studio 5 into version 6.
Apparently, the Standard C++ Library used in both products was produced by Dinkumware and they, with their illustrious author/founder P. J. Plauger, were embroiled in a multi-year copyright dispute which made it impossible for them to debug (let alone update) the library. Most of the commenters online seemed to believe that this problem could not be solved and we had to wait for the copyright battle to be resolved (it has).
My impression is that Microsoft has elected not to provide an update to the library (which includes the STL) until the release of .NET.
Karma: Bored. (Thinking about resurrecting the "Anyone else is an imposter" joke.)
how about find a suspected bug and then write a program test.c to figure it out.
cc -o test test.c
And then you are suprised that "test" does not have ANY output.
A variable is initialized.
Another variable meant to be initialized/assigned by an external process wasn't.
Assign the uninitialized variable to the one already initialized (thus copying the pointer)
Voila the program reports an uninitialized variable, which any fool could plainly see had a value set at the begining of code.
I've seen this happen in a couple languages, including c. The lesson is always assign some value to vars, perticularly when passing between routines, all return values should return with something other than a null pointer (unless of course you're coding for this intentionally.)
A feeling of having made the same mistake before: Deja Foobar
I at one point hacked a bit on uemacs. I liked emacs, wanted a small binary written in C with 95% of the functionality and 5% of the cruft. Anyway, I went to add a tab-complete to the dialog for opening a new file. No worries, the glob function is POSIX. So I wrote it in, and it worked fine under linux.
Then I went to our alphas to do the same. Glob didn't work at all. Something went wrong. Then I tried to debug it, and what I found was that the libc glob function on OSF unix (4) was calling ksh to perform the globbing function. I contacted DEC people via Usenet and they basically told me to piss off. Somehow ksh interpreted the session as not being interactive, and then its globbing was dysfunctional.
I ended up writing a work-around based on the algorithms in the glibc globbing code. I found it awfully strange that a commerical libc was dependent on ksh for its functionality (note: the DEC programmers that told me to piss off didn't think this was odd at all).
It's turn-back-the-clock time, boys and girls. Remember all of those DOS calls? It was interrupt 20, wasn't it? Remember the findfirst and findnext functions that would get you a list of the files in a directory? You could give findfirst a list of attributes and a filespec, and it would give you a file that matched it (findnext just repeated the last findfirst). Valid attributes to pass were the archive flag, read-only, directory, etc. Except the directory one didn't work! It was simply ignored, so you had to sort out what files were directories or not yourself. What a pain in the ass! And did they ever fix it? I'll give you one guess.
Oh, and I can't mention old MS bugs without mentioning MASM vs TASM (just because it illuistrates why Borland is so cool and MS is not). Back in the day, when applications were coded in assembler, MASM (Microsoft Macro Assembler) was popular as hell. Borland, though, came out with Turbo Assembler, which had a better syntax (optionally), could assemble MASM syntax faster than MASM could, and could emulate all the bugs in the different versions of MASM. Ah.
Well, that's enough MS bashing for me today (or maybe just this hour...).
I program in Delphi and there's nothing quite like getting a resize event for no apparent reason before an object has been created in the constructor or after it's been freed in the destructor.
I once wrote a piece of software for assisting staffers in calculating payrolls at a big ten university. This was used for budgets, paychecks, accounting, etc. Anyways, some of the employees started complaining that their paychecks were slightly off from what they should be. (Usually less than $.05) I found that I was summing the paychecks individually, propogating a rounding error. But that didn't completely fix the problem!
... one that can't be easily fixed.
It turns out (after a lot of research) that the budget office officially rounded down (floored) and the payroll office rounded to nearest! So here I was getting blamed for the annoyed employees, but it was really the worst sort of bureaucracy
-Sean
Will fix that for you.
You cannot apply a technological solution to a sociological problem. (Edwards' Law)
Implementing a custom file format where the header was an AVL tree.
I was using a textbook's pseudocode for an algorithm, and sometimes values would disappear from the tree. I finally figured out that there was a bug in the book's pseudocode. Of course I though the problem was in my code, not the book, so this one took a long time to catch.
-... ---
I was implementing a public key encryption algorithm for Java in Java 1.0 so applets could use it in the bad old days. I had to write a big-number package from scratch using algorithms out of Knuth vol. 2 since BigInteger wasn't in JDK1.0. I finally had it debugged on Windows, but I was getting garbage when I tested the apps on Macintoshes. Eventually, after many hours of debugging, I found that Netscape's JVM couldn't divide long integers properly, but only on the Mac, and only for certain values. You can imagine how frustrating it was that I was generating random numbers for every key, so the error would only occur once in a while.
The Netscape engineers finally acknowledged the bug, but it took them about 8 minor version upgrades of the browser before it got fixed. I ended up just hacking it to use a smaller internal radix on the Mac, which seemed to get rid of the problem.
On the note of this post, my favorite bug is something everyone who has programed in C has dealt with. The float and double. While this may not be considered a 'bug', when I first discovered that doubles and floats were so .. well unpredictable, I thought it was a bug. I know this has more to do with precession than a 'real bug' but to me I should be able to use a double on any platform and get the same results, but you don't always. On one machien I had precission of 2 decimal places and on another it was 6. It would be better if in the implementation it was 6 everywhere.
Compile and run this:
what do you get? On what platform?
Only 'flamers' flame!
In C:
Program was failing... inserting debug statements made the bug go away...
so the program ultimately ran with the following line in it.
int k = k;
'k' was never used anywhere else.
42 - So long and thanks for all the fish.
Back in the day when I used to program in C++, I was also really into making little ascii-art comments in my code. One time I had some code that looked like this:
#include <stdio.h>
// tom 7 was here - 1998 \\
typedef unsigned char uchar;
int something(uchar c);
...
(In actuality, the code was longer and more complicated, so it wasn't so easy to figure out...). Can you see the bug?
But I program in pascal so I'm used to "if x = y then". Do you know how much of a pain in the ass it was to learn Perl when I erroneously coded all my comparisons that way and I couldn't figure out why nothing was working because it was setting everything to valid numbers, just the wrong numbers. I'll admit that after I realized my stupidity I've been able to quickly find those buggers.
..there was the "loose connector" bug.
Machines that stay running for years at a time almost never come back up cleanly after some downtime, and I can't recall the cases where walking back to the beast and planting a kick into it's chassis would "fix" the problem. We particularily enjoyed doing this to aging RAID arrays and four digit sun machines because of the amount of effort needed to get the things out of the rack and opened up.
Now most of us would realize that this was probably just reseating whatever needed reseating, but the humor value behind skilled techs fixing expensive hardware with violence is too tempting to resist.
In other words,
digits 0,1,2,3,4 get rounded DOWN
digits 5,6,7,8,9 get rounded UP
This seems correct when you first look at it, but the correct statement is actually:
digit 0 gets nothing (-0)
digit 1 gets rounded down (-1)
digit 2 gets rounded down (-2)
digit 3 gets rounded down (-3)
digit 4 gets rounded down (-4)
digit 5 gets rounded up (+5)
digit 6 gets rounded up (+4)
digit 7 gets rounded up (+3)
digit 8 gets rounded up (+2)
digit 9 gets rounded up (+1)
Now add up all the pluses and minuses, and you'll find that the total is +5. That's because you're rounding TO zero, so zero never gets rounded. If you assume a random (i.e. even) distribution of all possible numbers, then you'll round up more than you'll round down.
With the even/odd system, half the time you get a +5, the other half you get a -5, so they cancel each other out.
However, we must remember that this is only used when there are no digits after the one we're basing our decision on. Therefore, 82.451 should be rounded to 82.5, and 82.449 should be rounded to 82.4; only 82.4500000... will be rounded to 82.4, and 82.550000... will be rounded to 82.6
"I have never let my schooling interfere with my education." - Mark Twain
Well, it depends on the data. If you're working with data that has one decimal place of precision:
4.4, 4.6, 4.5
If your measuring instrument has the (common) behavior of reporting the nearest value, then your scheme results in
Actual values 4.00 to 4.4499999... round down to 4.
Actual values 4.45 to 5 round up to 5.
So it's actually a 5% bias down in that case, because the instrument already rounded once.
Based on a true story!
A few years ago I was working as the lead programmer on a cd-rom game. Two days before deadline, the manager of the project decided that we should implement a copy protection.
Now you can see where it is going... right?
Well the manager had talked to the company who was going to print the cd-roms. They had this piece of software that would protect the system. All we had to do was to write a component that needed to be called in order to start the game. If this component weren't called at first the game wouldn't start. We thought about it for some time. As we only had two days, we decided to let the component write down an encoded string, based on the current date to the harddisk, and then inside the game, well hidden read the string and match the date. As I have coded the game I made the part inside the game, while an other developer made the start-up component. I designed the specification of the coded string. It contained a lot of crap, and well hidden, the two digits indicating the day.
Now I coded my part in such a way that it would work 4 days after the date. (Allowing me to more easily bypass midnight at the end of the month - especially February). This would hopefully also put off hackers, as the game would appear to be hacked, as the coded string would work for a few days.
We tested the system, especially the end of months, going from the 28-31st to the 1st. It was end of November, close to Christmas - therefore the hurry. Then the cd-roms went into print.
4 of December I received one of the first copies, just as the packages was prepared to be send out to the shops. I put it into the computer, and it failed... I tried again... and again. The way the program terminated looked subspecialty like the protection, so I started to look closely into what was happening. It was the date. 4 of December were a single digit. The protection component wrote 40 while the game looked for 04... My fellow developer had misunderstood the specifications. Of cause testing for 31 would work... it was two digits.
We trashed all the cd-roms and made a new version without protection. Our manager will probably not ask us to do such a change with such short notice an other time.
A thought thou; The cd-roms would have worked on Christmas eve... its two digits, but a new year... he he he.
-:) Oh no - not again.
www.rednebula.com
As others have noted, this isn't a bug, these are just the stories that the editors decided weren't important enough to warrant a full front-page thing. Funnily enough, these "section page only" articles tend to have much better and more insightful comments than the front page articles, because people only post there if they really care :)
:( Unless i'm just confused about how it's done, anyway. But it seems to be disabled, going to a non-existent sid now shows "Nothing for you to see here, move along".
Beyond that, though, what i liked was that used to, on slashdot, you could post to sid's that didn't exist. Like, you could go to http://slashdot.org/article.pl?sid=haiku, or something, and while there wouldn't be a story at the top of the page, you could post comments there, and the next person to go to http://slashdot.org/article.pl?sid=haiku would see that comment and could reply to it, until the comment reached a certain age and was automatically deleted. There used to be a whole bunch of these little "hidden" discussion areas littered all over slashdot that people would form entire little communities around them. Unfortunately, this was mostly used for troll groups to coordinate attacks. (K-9-something-inches or something? I don't remember.)
Unfortunately they seem to have removed this feature from slashdot
There were some other really bizarre but fun slashdot bugs, like how there was some wierd twilight zone area at sid 0, or sid null (or something.. "slashdot.org/?sid=", i think was the url.. i can't remember. i think it was called "test discussion". or something) that you'd sometimes get dumped at if you clicked on the "parent" link in the preview of a post you were writing. Not always, just sometimes. The thing was though, there was some other bug that for some unfathomable reason would sometimes cause posts to get moved out of their correct threads, and into the null discussion, at random. And people wouldn't notice this. And so if you went to the test discussion, you'd just see hundreds and hundreds of random posts, totally irrelivant to each other or anything else, on totally random subjects. It was fun to go through this and try to guess what subjects the posts were on.
And then there was.. i barely even remember this one. There was a page i managed to get to a couple times-- i can't remember how, but there was a simple way to do it that would work every time-- that just said, "Here are some open discussions", and linked a bunch of articles. The Test Discussion was always near the top of this list. I'd expect that whatever this page is, it's gone now, but can anyone remember what this page was or how i would have gotten to it?
Irritable, left-wing and possibly humorous bumper stickers and t-shirts
I was trying to debug a CMOS standard-cell chip that I designed in the late 80's. The bug was elusive, only showing up occasionally and I'd written various test routines to ferret it out. I started to suspect it was something to do with the PCB layout, so I was cutting and pasting tracks. Suddenly all the test routines worked perfectly and I thought GOTCHA! My mind was almost blown when I realized that I had inadvertently cut the power trace to the chip - it was working perfectly when Vcc wasn't connected!
Of course, I eventually figured out that the original problem was ground bounce and that with Vcc disconnected, the chip was getting power through the protection diodes on the control lines and bus. The lower voltage was slowing down the edges and reducing the ground bounce so that it worked correctly. I eventually solved the problem with PCB layout changes and the chip started working with Vcc connected!
Look, it's trying to think - Albert Rosenfield
While working on the graphics engine for ArmyMen for PSX, I wrote a little bug that always set one vertex of every terrain polygon to the center of the screen.
Being an over-the-shoulder shooter, this was naturally where your Army Man's head was...it looked like one of those medieval illuminations of saints with the rays of light coming out of their head. Only these rays were the terrain.
We named that piece of art "Army Man Creates the World"...
Sucks to be a Windows user.
-g.
Netscape 4 has always had a feature where if you don't close a table cell or row before opening another one, it assumes it's still in the old cell or row. Microsoft decided at around the same time that when a new table cell or row starts, the old one is implicitly closed (unless you've explicitly started a new, nested table, of course).
Now Mozilla and Opera mimic IE's behavior, and the more I think about it, the more it makes sense. After all, it's always been the case that if you don't close a paragraph before starting a new one, the old one is implicitly closed. And how can you start a new table row unless you end the old one?
So the feature of NS4, which formerly enforced the closure of table tags in a nice programmer sort of way, is now more like a bug, which can completely scramble my (and others') HTML page layouts which had been developed and tested on IE or Moz and only tested near the end at the less-used NS4.
The more I use Moz, the more I hate that browser... and the fact that I seem to be the only employee who knows Netscape has a new version out these days.
I had a cage of Giant Australian Walking Sticks once. They were pretty neat...
That is all.
Here's one I never fixed.
..). Anyway it was close enough that when I glanced at that part I didn't think anything was wrong. I debugged the hell out of everything else. Took 10 minutes to find where it was =) 10 years won't be long enough to get over the shame...
I've found that every time I use any function referenced in , I end up with a character with value 0 (I'll call it 'NUL') tagged to the end of every string! weird, eh?
I never solved this. I just have this grotesque hack that from now on whenever I reach a 'NUL' in the string I assume I'm at the end of the string.
=)
april fool's, folks.
Seriously though, most bugs that became memorable I don't want to talk about.
I make typos when I type, and once when calling malloc, instead of doing malloc(nmemb * sizeof(char *)), I missed and wrote malloc(nmemb * sizeof(char )) (My finger slipped when hitting the * ??; notice the space after 'char'
My last day on my first real programming job... hoping to spend it saying goodbye to my friends. But noooo...
Quick bug summary... there was a BLOB column in a Sybase table, a legacy from some code changes i had done that summer. But nothing was being written to that BLOB, so it shouldn't take any memory, right? Right? Well. The system was a batch workflow that moved a LOT of data. First day of a production run was my last day of work. The system started, and the database started filling - fast.
Turned out that some ancient library that predated me initialized the BLOB field with 0, not NULL. This caused Sybase to allocate a page (4096 bytes) for the BLOB field. Ouch!
At least i found the bug before the entire system came to a grinding halt... but it pretty much ruined my last day there.
Hand me that airplane glue and I'll tell you another story.
I just figured it out. In vi, make a mark named "d" ( for those who are limited out there, do this by simply hitting "m" and then "d", no ":" is required ) next move down a line ( "j" key, or down arrow for the limited ones ) Then hit do a change to that d mark. ( type c'm ) Do this on Solaris and vi will core dump. vim 5.8.7 on Redhat 7.1 seems to be fixed.
Here's one I inherited.
We had a system we were building (about 250K lines). If you pounded on it continuously, it ran fine. However, if you left it alone for about 2 hours, it would crash.
Turns out that there was a bug in the (homegrown) executive's timer queue logic.
Another one on the same system.... We were just about to go into FQT (this was a DoD contract), and an error code pops up. Now the problem was, that this happened 6 hours into a 10 hour test, that required 8 people to run various machines. Not fun.
The machines were communicating via tactical radios using analog FSK communications, so what they wound up doing was this: They hooked a stereo tape deck into the system, ran the scenario, and recorded all communications. Then they played it back, only to the system that had the problem.
The system was running a Z8000 at the time, nice chip but no memory protection. Turns out it was a third order effect (A corrupts B, which causes C to be corrupted, leading to the error), caused by a -1 index being used somewhere.
Fascism starts when the efficiency of the government becomes more important than the rights of the people.
Yours is maybe the 4th mention I've ever seen online about the good old ICONs. Unisys made quite a powerful little machine for the time, and I wasted many an hour tinkering with some of the (for the time) advanced apps (the vector morphing software was pretty damn cool!).
Any chance you know where one could accquire one of these rare beasts? I've yet to see one on Ebay, or anywhere else for that matter - and I know they were very common in high schools in Ontario during the 80's.
Endless arguments over trivial contradictions in books written by ignorant savages to explain thunder in the dark.
There is no "proper" way to reduce the precision of a number under all circumstances. Each method of rounding or truncating 0.5 has its own pitfalls:
So, as you can see, there's no right way per se. It just depends on what you're doing.
--JoeProgram Intellivision!
I'm sure everyone has their favorite code that MSVC 6 chokes on.
/* missing: () */
fatal error C1001: INTERNAL COMPILER ERROR
class Test
{
public:
Test();
};
Test::Test
{
}
Anyone know if this bug still exists in MSVC 7 ?
This goes way back, but if memory serves correct the original PC-Basic 1.0 interpreter, that was shipped with PC/DOS 1.0, would report that 1 + 1 = 1.999999. Needless to say version 1.1 was shipped shortly thereafter.
"To those who are overly cautious, everything is impossible. "
if you had multiple source files, you had to be sure that you left extra lines at the end of each file, due to the way the files were cat'd together before being processed into C files...
... hi bingo
I think it was Adobe at least, anyway if an error occured while using the scanner a dialog box would appear with the text
"Bummer man, there was a TWAIN error"
"For a successful technology, honesty must take precedence over public relations for nature cannot be fooled." -Feynman
I worked on an embedded box that had a problem keeping track of time across reboots; that is, it kept time fine until you rebooted it, and then it reverted to some other wierd time. (Actually the situation was more complex than that, but for brevity...) Anyway, turns out that the problem was that when we tried to read from the hardware clock (which reported time as a series of BCD digits) the memory (or bus or whatever: IANAH(ardware)E(ngineer)) lines which were connected to the bits that were never used, such as the upper two bits of the 10s place of the hour, were high when the box was turned on and were never initialized back to a low state and those bits weren't masked off when we read the time, thus, when we did error checking on the time, it turned out to be invalid.
if anyone cares.
I don't know if this is a fixed reprint or not.
Data Structures and Their algorithms
-... ---
I'm a web dev, so I'll go with: Netscape. Any 4.x version.
I don't think there's much point in trying to get more specific than that. Still, if you really force me, for out and out stupidity, it's a cross between:
- When assigning borders in CSS, under certain circumstances, it'll duplicate all bar the S in style of the tag. So you end up with <div Style="blah"><div Ttyle="blah"> instead of the single tag.
- The other stupid one goes to its handling of Java applets where, if they're inside divs, it regularly forgets that, when you leave the page, it'd be a really good thing to close them too. As a result you end up with music continuing to play or flash animations continuing their image updates over the next page you visit (Flash being, essentially, just a java applet).
I'm not even bothering to go in to page sizes that have to be multiples of 3, inconsistent syntax or the things it just plain doesn't support.Yeah, IE is bad, but it tended not to be so rampantly insane.
Moderated: -5 Daring to choose MS over anything else on Slashdot.
In the mad, mad world of Netscape 4-series' horrible CSS implementation, one of my favorites is in background-color (or any color property). If it encounters a string, it assumes it is facing one of the vast pantheon of "named colors" and insists on inteprreting it as such - which is handy for typos but not valid CSS like "inherit." Got a demo here, which links to a demo of similar behavior in all modern browsers as well as ns4.
Another excellent bug is in Opera. If an A element is set as block-level - that is, you give it display: block; - it will suddenly have an overline. The underline will disappear, and an overline will take its placed. So, if you're display: block'ing your A's, you gotta be specific about text-decoration (fortunately, most block A's are for sidebarish type things which will usually have text-decoration:none; anyways, but it's still a pain in the bum
Karma: T-rexcellent.
Another way to look at this is to make sets of only the numbers that change, then '0' is not in *either* set, so they are again unequal in size.
I tried to report this same issue regarding Javascript 1.0 waaaaaay back when that was something new. I got completely trounced on the newsgroup I posted to (interestingly, the person responsible for the implementation was the only one who was reasonably nice in his explanation).
/. didn't exist then ... it was embarrassing enough to get trounced by developers on a reasonably obscure newsgroup :)
Lucky for me
It is more productive to voice thoughtful opinions (reply) than to judge (moderate) others.
Can you say "Bluescreen"?
Pi
http://bugzilla.mozilla.org/show_bug.cgi?id=35011
Quote from the bug:
I'm glad to see that this bug hasn't been left to the wayside. If there is any
chance that this will not be finished for 1.0 I'm willing to sponsor it, if that
helps. I don't have much money but could probably sponsor the bug for about $500
USD, if that is what it takes to get it finished for 1.0
And several more developers claiming that they have been (privately, in email) offered money to fix that bug.
Is this a new way to make money in the open source realm or what?
Jobs? Which jobs?
Back when I still ran Windows, I used Windows 2000. One of the most annoying bugs I found was one with Mozilla installed as the default browser.
What I usually did was hit the windows key to bring up the start menu, go to the run line, then type in a URL and press enter. This loads your default browser. However, a certain Win2k security patch (I forget which one, it's been a while) would break this behavior; pressing enter would still load Moz to the page I typed, but immediately after I would get an Error Dialog from Windows saying that the location could not be opened. Mind you that if IE was the default browser, this wouldn't happen.
Not only very annoying, but it took a very long time to figure out which patch caused the break. It also seemed very dubious, as it only caused the error when a browser besides IE (I've heard it did this with Opera too) was the default.
This program will crash Windows NT with a BSOD. This works on NT 4, Win2K, and WinXP from an *unprivelidged* account. There is no known fix available from MS.
;
A /c srss-backspace-bug.html
main () {
for (;;) {
printf ("Hung up\t\b\b\b\b\b\b")
}
}
More information is available at:
http://homepages.tesco.net/~J.deBoynePollard/FG
This is why I don't run windows.
Using your sig line to advertise for friends is lame.
'round(82.845)' returns '82.84' instead of '82.85'
OK, my guess is that since the value is stored in binary, 82.845 is not a rational number anymore and it is stored as 82.849999... Rounding that to 82.84 would then be correct.
Opus: the Swiss army knife of audio codec
On a i686 running Linux and using gcc this program:
void main() { .1) printf("%g ", i);
double i;
for (i = 0; i < 1.0; i +=
}
Produces this output:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Notice that it printed "1" even though it looks like it shouldn't.
The reason that round "isn't working properly" is the law for rounding when the last digit is a 5, is to round to the nearest even number. That is one of the 4 main rules for significant digits. Here are some examples of this rule.
85 = 8 x 10^1
80.35 = 8.04 x 10^1
80.25 = 8.02 x 10^1
125 = 1.2 x 10^2
135 = 1.4 x 10^2
Test these examples, you'll find they're all correct. As for favorite bugs of mine, I just love the bugs that I DON'T have. =)
// TRiPTMiND \\
Took me forever to figure it out, becaue $_ wouldn't be left with something the function set it to, it would be... blah, forget, nonsensical. To get around it I had to use a temporary variable and set $_ to it's old value after calling the function.
There were 3 cases where I saw this bug, I haven't noticed it in any recent versino of Perl.
Anyone else ever see this bug?
Sticking feathers up your butt does not make you a chicken - Tyler Durden
We are pentium of borg, you will be approximated.
Some people have a way with words, and some people, um, thingy.
random() only returns 666 if you use a demon seed!
My favorite "bugs" are the truly horrible random number functions in almost every single language library on earth. They're usually linear congruential generators: fast, but utterly useless for any work that requires serious "randomness" such as Monte Carlo simulations. They have very short recurrence times, strong sequential correlation, etc.
Back in grad school, I had to substitute the Knuth ran3 routine for the supplied C library functions in both gcc and xlc since they were just awful.
Fast forward 8 years. I made the stupid assumption that since Java was a new language and that horrible problems with random number generators were well known that Sun would actually provide a decent RNG. Nope: just as badly flawed as the C one.
I suspect this is simply something to give up tilting at windmills about: random() is good enough for simple games and anyone doing real work knows to stay the hell away.
"Seven Deadly Sins? I thought it was a to-do list!"
We've ran into hardware bugs that kept crashing a Linux cluster. We've had OS `upgrades' that made P^2 point-to-point communications more efficient than log P collective communications. We've had debuggers that crash. Profiling routines which don't, due to library incompatibilities. I/O libraries with bugs. SCSI controllers which eat a RAID periodically.
And your worst bug, the bug that took you forever to figure out, was that the rounding behavior of a round function was something you hadn't understood, and which the top result of a Google search explains completely?
AARRRGGGHHH!!!
One of the most frustrating bugs was one I encountered in an early programming class in college. I had finished my program, and was testing it. Of course, it wasn't correct. I fixed every bug I could find, but it still wasn't correct.
So, not knowing about fun things like debuggers, I started putting some cout statements in the code, to check the value of variable at different locations.
The variables were all correct. And so was the output.
I started removing cout statements, and found out that when I removed one particular statement, the program started giving incorrect values again.
Print the value, program output was correct. Don't print the value, it was incorrect.
So, I experimented some more, and found that I could do a variety of things, such as swapping a couple of my statements, and the program ran correctly without the output of the value.
I pretty much forgot about this, until another class a couple of years later. We were using the same compiler (I beleive it was Borland 5), and I found the exact same problem. This time, however, I couldn't swap statements around to get it to go away. I needed a statement that would do nothing.
So, I gave up and assigned the variable to itself. (i = i;).
Imagine my surprise when the program worked correctly. I brought over my TA, and she couldn't make heads or tails of it either. But every time, if that assignment was commented out, the program was wrong, but if it was left in, the program was correct.
I eventually learned about pipelined instructions, and how a compiler has to be careful that a memory address has the correct value before using it for another statement. I'm pretty sure that's what was going wrong, but I always remember my magical solution of assigning a variable to itself to make it the correct value.
I was developing a library which used glib for some of its module code, and while I was at it, I used it for the string functions as well.
Well, my library was crashing, hard, in the middle of a complex io cascade (read some file, and decided to load a module to read some other file based upon istructions in the first file, etc.) and I had checked and rechecked and rechecked the code. The code was correct, but the damn thing was crashing.
And it was crashing in some of my code, which was _perfect_ (I spent like 3 days on this, that code was checked, bracketed on both sides fully by debug statements, etc.).
Oh, and there had been perfect output from the program up to that point. So, getting another hacker to take a look at it, someone much more familiar with glib (One of the maintainers, actually) it was determined that using the %a format in my output was hosing not the print function, because glibc understood the C99 format character for printing floating and double point numbers with out loss, but in the glib code which estimated memory bounds on string operations before calling through to the underlying sprintf implementation. So the heap was getting corrupted, but it was printing out the correct value.
And then it died later, in my code, when it triped over that heap problem. Much profanity was involved.
-- Crutcher --
#include <disclaimer.h>
On my computer there's a thing called "gcc". IT seems to be something that causes people to write code with buffer overruns and stuff...
Liberty uber alles.
I recently built a new system using a FIC AN11 Stealth motherboard. Since it was for a non-geek friend, I installed Windows XP.
When the machine is shut off, either through software or the "soft" power button, the motherboard still provides power to the PS/2 ports. Therefore, the optical mouse and the keyboard are still lit up!!
A quick search in Google Groups revealed to me that this was not a defective board and is a "feature" (I'm now told that FIC has since released a BIOS update to turn this "feature" off)
Pretty much all of Netscape ... especially the 4.x breed.
Has a rather funny error message when you try to run an older version of Photoshop on a very new Mac (G3 or later).
Check it out.
Very Brittle is an understatement.
I was working on a project using VB *sigh* a few years ago when I discovered a very peculiar bug. In order to get a form to appear, I was forced to call DoEvents() - TWICE IN A ROW!!!! I guess VB thought I didn't mean it the first time.
I was writing a Q3 mod, coding in VC++ and then compiling with the bytecode compiler (LCC I think?). Code was working perfectly as a .dll and crashing as the bytecode. I couldn't do any real debugging; that's what the DLLs are supposed to be for.
Turns out I was being an idiot and using an if statement with variable == "string" instead of !strcmp(variable, "string")
VC was smart enough to optimize the code and factor out duplicate entries from the string table. So in the DLL, I was comparing two pointers that (ultimately) pointed to the same location. LCC wasn't smart enough to do this, so it was pointing to two different memory locations that just happened to contain identical strings.
DOH!
Trolls throughout history:
Jonathan Swift
It's a bug, but the platform is irrelavent.
DMCA, Hollings, Palladium. What might have sounded like paranoia is now common sense.
Here's one we are all familiar with. I suspect it occurred because the engineers involved used Visual Basic for their calculations and design work.
the "bug"
He looked at me and said, "Kid, we don't like your kind, and we're gonna send your fingerprints off to Washington."
Bad bug: If you boot from the Windows XP CD... it installs Windows!
The global economy is a great thing until you feel it locally.
I hope your post is a joke. You round 0 down? To what?
My apologies if I missed the sarcasm. I was always taught to round 5s to the nearest even digit.
No, not a joke - I'm serious. This is pretty basic (and common) mathematic thinking. In fact, it's starting to bug me how many people (including the brainiacs at MS) are in your camp on this. Ultimately, I believe the problem is that the intellectual neophyte that came up with this idea forgot to consider the case where ROUND() hits a zero digit, so (of course) the statistics are off and he tries to correct by 'splitting' the case where ROUND() hits a 5 digit. Stupid. It's a perception problem more than anything else, but it does expose a lack of formal mathematical training because (believe me) these kind of 'trivial' cases come up *all* the time in formal function definitions.
Yes, you round 0 'down' to 0. What's the problem - ROUND(0) isn't defined? There are ten digits between 0 and 9 (inclusive). The ROUND() function divides this space in half - half of the digits can be considered rounding down and half of them rounding up. There is no need to consider 0 an exclusively special case and start pulling statistics (of all things) about the number 5 into this. If it bothers you that ROUND(0) is considered rounding down, I'm not sure what to tell you, except that rounding YOUR way divides the rounding possibilities into three categories (up, down, none) that throw off the statistics even worse because neither the up OR down case ever hits 50% utilization. (Nobody seems too concerned in this debate what percentage of the cases shouldn't be rounded at all!)
My basis for defining ROUND(0) as ROUNDING DOWN is based entirely on understanding what the rounding function actually does. (Ironically, I best learned this taking lab measurements in physics, not math.)
More formally, it's a bit easier to see if you define your rounding function something like this:
ROUND(X) = TRUNCATE(X+1) if tenths digit is 5,6,7,8,9; TRUNCATE (X) otherwise.
In my opinion, you were taught incorrectly.
"Lawyers are for sucks."
- Doug McKenzie
Zero is rounded down? I suppose that's true, in the same sense that ten is rounded up.
This space intentionally left blank.
It's not necessarily 'correct'.
It's one way of rounding, I *think* used with large statistical sets to reduce overall rounding errors.
It also creates problems though, so using it to say, rounding for sigdigs is wrong.
Consider the case in which you only have one digit of precision to the right of the decimal. Consider the set {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}. If you sum these numbers, you get 4.5. If you round using your method and then sum, you get 5. If you round using the "round down when the whole number part is even" method, you get 4. Each method has the same amount of error.
Now consider the set {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.6, 1.8, 1.9}. If you sum *these* numbers, you get 19. If you round using the "5 always goes up" method and sum, you get 20. If you round using the "round down when the whole number part is even" method and sum, you get 19. One of these methods is not biased...
Unlike PHP, most other languages that do this don't do it internally either. You can't use PHP internal functions like sort() because they copy object. You can't do variable assignments: $object1 = $object2 and get a proper result.
It's never OK to implicitly copy an object. Ever. And the people who designed PHP did later correct their mistakes somewhat in the latest version of PHP, so that object assignments are real assignments, not duplications.
-- Ken Kinder ken@_nospam_kenkinder.com http://kenkinder.com/
Ah, Icons.
:).
The ones at my old high school were especially badly maintained. When we finally switched to PCs, I wrote a TSR that used palette shifting to fade text in and out like the dying monitors on the Icons we had to use earlier
Much nicer games than the PCs initially had, though.
I didn't have one, but I heard from our Apple tech guy.
The Apple III was a much unloved "business" computer, essentially a business upgrade to the Apple ][ line. It was pretty expensive, $4k I think, which helped it be unloved.
It had some loose connectors in some of the chips. They weren't very snug in the bboard and could get loose. The Official Apple solution was to put the Apple on a hard surface, lift the front to roughly a 45 degree angle, and drop it to reseat the chips. I can imagine the look on the face of the owner upon seeing their expensive comp wandering to the the back room, a loud THUD, then returning with it "fixed".
My favourite software bug
has eight spindly legs
cut one off
it will grow two more.
My favourite project
is the ointment of my soul
and my favourite bug
is the fly in it
laying thousands and thousands of eggs.
My favourite bug
keeps me company at night
in my nightmares
snuggling between the lines
comfortable in the software.
Going nowhere.
"I have opinions of my own, strong opinions, but I don't always agree with them." -- George H. W. Bush
The Radio Shack CoCo had a similar parser problem. The basic commands "GOTO" and "GOSUB" were combined together into the tokens "GO", "SUB" and "TO". I wrote a simple dungeon program using the variable "GO", which failed to work at all. Changing the "GO" variable to something else fixed it. It was much later that I found out why.
Ah, the days of two letter variables...
It seems that a lazy computer operator (remember those guys?) didn't like getting up from his chair to separate the users' print jobs. So, laziness being the true mother of invention, he created a job trailer banner page that included hundreds of overstruck lines completely filled with "_" characters. These had the effect of hammering a line across the paper that eventually cut the paper off at that point.
Apparently, the drum printers of the day couldn't survive hitting all solenoids simultaneously on every rotation of the drum, so they were overheating, causing (at least) some serious smoking, and maybe a bit of excitement.
Back in high school, computer programming class using Apple IIe, class is learning to type simple 5 line programs, I'm in back of the class keying code for a space invaders game, the teacher is explaining to the class how to swap the values of two variables (my syntax may not be Apple ][ compliant but it was something like this)
10 $A = 10
20 $B = 20
30 $A = $B
40 $B = $A
50 PRINT $A
60 PRINT $B
...so the class enters this code and runs it and everyone sees "20 20" on their screen instead of "20 10" and the teacher for the life of him can't figure what the problem is... so I let them discuss it for while I'm tweaking my game code and eventually I go to the board and write
A = C
A = B
B = C
The class was baffled that alogrithm worked, so was the teacher. This is why there will always a job market for computer programmers.
two for you.
... yep bug in the system.
1. 1988 somewhere in a Gov installation on the East Coast of the US: I enter the Switch room (Telephone) and find that all 3000 of the relay's in the switch are opening and closing in sync with the clock relay. Phone calls are going through.... but it's still not right. 48 hours later we find the problem. A large wood roach had crawled across a -48Vdc connection point grounded himself out and
2. Microwave tower: Operators noticed that the secondary antenna began degrading rapidly over a two day period. All testing lead to the belief that something must be wrong with the antenna horn. So an antenna team was dispatched to check out the horn. Fortunately when they got up there and before removing the cover someone first noticed a loud buzzing sound, and then a small hole near the top had a lot of.... yep BEES comming out of it and going into it. A peak under the cover reveiled that bees had decided that setting up housekeeping inside the cover was a good idea. The hole they were going through was known but since it was less than 1/8th inch in size originaly it fell under the size needed to "demand" a replacement. The bees did manage to both enlarge the hole slightly and use it to set up a huge nest. Next day.... beekeepers where found to begin learning how to climb up a Tower to get rid of the bees... (Note the Honey is a bigger problem than the bees, without bees to keep it cool you have a HUGE runny mess.)
I'm sorry, I'm to tired to be witty at the moment so this message will have to do.
Random Static Variables
In some primitive embedded OSes, there is no initialization of globals and statics to zero. This can cause havok when you're trying to port programs.
Registers that refuse to latch
"I'm sorry, but sometimes when you write the hardware register, the value doesn't take if the hardware is sufficiently doing something else - we're not going to turn the board, can you fix it?"
Leads to code like this:
do *reg = newValue;
while ( *reg != newValue );
Interrupts that don't
'Nuff said.
Hardware interrupts sometimes need more processing than CPU can deliver before the next interrupt comes along.
This one is a beaut. Wierd things happen in your system, and you have no clue where to look.
"Did I mention, in order to perform this HW feature you have to turn off memory refresh?"
There is only one solution to this - murder the HW designer.
Maybe next time I'll talk about the top dozen software bugs.
Arrrrrrggg! That was the problem?!??
(Used to write on Linux and BSDI and Solaris, remember distinctly that the Linux version would break for no apparent reason)
Libertarianism is rich wolves and poor sheep playing gambler's ruin for dinner.
If you did sequential SQL executions in ASP using Jet with ADO, the second SQL command would not "see" changes made by the first one sometimes. After tons of digging around and playing with configurations and transactions, I found the following phrase in a remote MS document: "This caching behavior cannot be turned off." (paraphrased)
My work-arounds grew real messy and CPU intensive.
Rumor has it that they decided that fixing it would cut into MS-SQL-Server sales. Their biggest competitor is themselves.
Table-ized A.I.
... and that's why there also be a job market for debuggers!
They're like walnuts, only evil!
A Long time ago I was working on a project which was being built on a pair of single-board Motorola 6800-based computers. (Yes, 6800.)
I was in charge of some of the display code. The unit would display results on a thermal printer and an LED display. The problem was... the results were displaying as random junk.
A fellow undergraduate working on the project and I looked long and hard at the code, but everything seemed ok. Then, after about an hour or staring at the code, one of the grad students on the project came up behind us. This fellow pointed at something on the screen and said "You can't do that" and walked away. We stared at the screen and it hit me...
The 6800 had two accumulators, A and B. They were identical except... you couldn't do decimal conversions in the B accumulator! I had forgotten that DAA was Decimal Adjust AccumulatorA, not Decimal Adjust Accumulator. Duh.
A quick breese through the editor, a run of the cross-assembler, and a long time manually punching hex codes into the EPROM burner (no sense buying an interface to the burner when you have free undergrad workers!) and the display unit worked!
I don't think I'll ever forget that one.
Milalwi
Its gone and infected every single line of code I've written for M$ Windows!
[Please type your sig here.]
Ok, here's an exercise:
For a = 1 to N
x = random (1.0, 100.0)
round_sum += round(x)
whole_sum += x
I assert that if you use the rounding algorythm you describe, round_sum and whole_sum will diverge as N gets bigger, and that this is a bad thing. This will not happen with the other method.
The problem isn't our lack of formal mathematical training, trust me...
My favorite bug isn't actually a bug, but I do consider it something they should have addressed when they did the ANSI standards work on C.
...
...
...
...
The failing program contained a fragment like this:
switch (someResultCode) {
case SOMECODE_01:
break;
case SOMEOTHERCODE:
break;
otherwise:
fprintf(stderr, "Unknown blamnitz in the framitz\n");
break;
}
Do you see the problem with this yet? Four well experienced C programmers (including myself) were given this fragment by a C newbie who couldn't figure out why he was getting funny results (the cases actually did calculations, not ellipses and an fprintf).
We stared at the code for hours. It compiled cleanly, no errors no warnings (from our compiler -- some do flag this with a warning these days).
The problem is the newbie wrote "otherwise" instead of "default." We all read what he meant, not what he typed. I think we all also assumed you would get a compiler error if you misspelled this keyword in a switch. The trouble is the C grammar merrily accepts this error as a label (the target of a goto. You know, those things they tell you never to use?). So we have a block of code with an "otherwise" label, but the switch has no "default" case.
Personally, I wish ANSI had required that labels be declared. It wasn't that radical a departure from what had come before in the evolution of C, and it would have flagged this kind of error right away ("Undeclared label "otherwise" at line XXX").
Does anyone know if the (was it the X3J11 committee? That rings a bell anyways) ANSI C committee ever considered this, and if they did, why they rejected it? Other than breaking old code, what good reasons exist for NOT requiring the declaration of labels?
So, my compiler bug isn't really a compiler bug, but I think it should be!
this is not exactly a bug but it's still my favorite...
A programmer at a major aerospace company modified the UNIX login to have a little man dance
across the screen of the first workstation logged in each day. This was an amusing and well liked "feature".
However nothing is forever and one day workers couldn't log in. The login would get the username and password and just hang.
You've probably guessed this had something to do with the little dancing man, and you're right but it took a very long time to figure out. All the workstations had been upgraded over the week end, the dancing man could not dance across the new screens. No dancing man, no login.
Now all that needed to be done was login and kill the little sucker. Log in? Well there's the rub, no one could.
An exhaustive search finally turned up a locked office that hadn't been upgraded to the new workstation.
Login accomplished. No more dancing man.
Lesson learned.
If you're not living on the edge, you're taking up too much space.
0 doesn't round to anything -- it stays unchanged, as 0. If you round 0,1,2,3,4 down and 5,6,7,8,9 up, you end up with a small upward bias, because *on average*, your rounded values will be higher than your non-rounded values. If you round 5 to the nearest even digit, then your rounded values will average to the same as your non-rounded values, which is clearly better.
I wrote a simulation in PHP to see which rounding method is more accurate. Even rounding was an order of magnitude more accurate (about 0.01% off, vs. 5-up rounding being 0.1% off).
Try it yourself. Take a random set of numbers and see which are, overall, more accurate given one method or the other.
"Destroy science and religion. Science would re-emerge exactly the same; but not religion." - Penn Jillette, paraphrased
I didn't see any problems, ran the code and worked as expected. any more details? did you have problems with char/int interpretations?
//int op = '*';
//operator * ;
I tried this and it did what I expected (as written here, garbage come out for v, if you toggle the commenting you get 6):
#define OP_MULT '*'
#include <stdio.h>
int main(void) {
int v;
int a = 2;
int b = 3;
int op = '-';
switch(op) {
case OP_MULT:
v = a*b
}
printf ("op is %c, v is %d\n", op, v);
}
Liberty uber alles.
a = , b = , c =
a = please, b = fire, c = timothy
Before submitting the bug report (and looking like an idoit), I dig some digging and found this in Programming Perl (section 2.7):
Subroutines may be called recursively. If a subroutine is called using the & form, the argument list is optional, and if omitted, no @_ array is set up for the subroutine: the @_ array of the calling routine at the time of the call is visible to called subroutine instead. This is an efficiency mechanism that new users may wish to avoid.
Personally, I don't really buy the efficeny argument. I understand in recursive programming it could be perceived as a big savings, but let's look at how much time it actually saves:Benchmark: timing 100000 iterations of Fast, Slow...
Fast: 0 wallclock secs ( 0.48 usr + -0.01 sys = 0.47 CPU) @ 213333.33/s (n=100000)
Slow: 0 wallclock secs ( 0.62 usr + 0.00 sys = 0.62 CPU) @ 162025.32/s (n=100000)
So far 100,000 function calls, the savings is
-Bill
SlashSig Karma: Excellent (mostly affected by moderatio
Java's random number generator probably just calls the platform's standard C library rand(). To get truly random data, you can use /dev/random on Linux and CryptGenRandom() on Windows.
cpeterso
Back in the days of DOS programming, I was really fond of Turbo Pascal 6.0 from Borland. So I used it a lot. A whole lot, actually.
It had two modes of operating in terms of I/O checking - either it would fire a run-time error (when using the {$I+} mode), or it would silently assign the variable IOResult an error code (when using the {$I-} mode). Weird system, but it worked - sort of. The problem was, that after exiting a piece of code operating in {$I-} mode, and NOT reading the IOResult variable before switching to code operating in {$I+} mode, whatever I/O operation you performed would fail for sure, and the run-time system would report the error as the one I didn't read out of IOResult. So I could get "File Seek Error" or something when simply printing a string on the screen.
That took me a *long* time figuring out, and after I had finally figured it out I contacted Borland, and they admitted that it was a bug on their part, but that they weren't going to fix it, since a simple workaround was to always assign the value of IOResult to a dummy variable upon leaving a {$I-} mode section. That helped me switch to C programming - thanks Borland :-)
Black holes are where God divided by zero
This is my favorite "supported" bug in Perl:
:)
my %editors = (
'good' => [ qw{CmdrTaco Hemos CowboyNeal chrisd Cliff} ],
'bad' => [ qw{timothy michael jamie} ],
)
That allowed dangling comma on the last line makes it easy to move lines around, etc. It works with any list structure in Perl.
Pretty nifty.
-Bill
SlashSig Karma: Excellent (mostly affected by moderatio
There are implementations in C, Java, PHP, Fortran, Excel (I assume VBA) and probably others.
I only have experience with the Java impl, and it is very good. There are two classes, MersenneTwister, which is a true descendant of java.util.Random, and there is also a MersenneTwisterFast class, which does NOT inherit from Random (same public methods, and identical algorithm though), but clocks in at about twice the speed, due to tricks like avoidance of synchronization, and method inlining and finalizing.
"Mind, as manifested by the capacity to make choices, is to some extent present in every electron." -Freeman Dyson
Quite quickly, the problem was discovered -- a block move instruction was testing for "less than" rather than "less than or equal to" in its carry emulation. But, this being ROM, there was no way to patch the bug short of shipping new chips. Atari acknowledged the bug and promised it would be fixed in ROM BASIC B.
Since the bug was so obvious, well understood, and easily fixed, a very junior programmer was assigned the task of fixing it. He found the offending 'lt' compare and changed it to 'le'. Then his eyes wandered to the neighboring routine, the block delete support function, which was doing similar block-move logic. There, he saw a 'gt' (greater than') compare. "Aha!", we can be sure he thought to himself. "I'll fix that one, too, and win praise from my boss for being proactive!" So he changed it to 'ge', submitted the code, and moved on.
Needless to say, the second compare was supposed to be 'gt', not 'ge'. Unfortunately, nobody caught this in code review or testing. Days after ROM BASIC B shipped, it was discovered that now, if you deleted a positive integer multiple of 256 characters, the system locked up.
This became known as the Atari "Jumping Bug". ROM BASIC C finally corrected it, ending fears that instead it would lock the computer on 256*n inserts and deletes.
When all you have is a hammer, everything looks like a skull.
0.5 can of course be stored exactly in IEEE format, it is 1.0*2^-1 ...
Note also that IEEE doubles give you 52/log2(10) ~= 15 full digits of mantissa. However, the exponent is 10 bits plus a sign bit so you get 10/log2(10) ~= (very almost =) 3 digits of exponent. (The exponent also has a sign bit but you didn't include it in the 52 figure... 52+1+10+1=64)
I don't know why you said that about packed decimal, that takes 4 bits per digit... Is there any other way?
The iterator is invalidated when you delete from a container, that's simple enough. To do what you want, just remove_if(hash.begin(), hash.end(), func). Where func is a Predicate constructed as required. Described at:
:) And it matches what you're doing quite nicely.
http://www.sgi.com/tech/stl/remove_if.html
It's not annoying at all really.
Cheers Koz
A classmate of mine bought a really cool Giant Hissing Cockroach for an English project, and named his Gregor. Cute little guy - I hope he found a good home -
Oh, wrong kind of bug? Nevermind then.
I'm the stranger...posting to
Compile short fortran program
"Internal compiler error. Please contact IBM representative"
Re-compile from command line using command history.
Compiled fine.
Curtains for windows?
I once had to debug someone else's code that looked vaguely like this:
READ A,E,I,O,U
[...]
X=A+E+I+0+U
See the problem? Note that in 1976, programmers would write their code on a form that was given to keypunch operators, who "typed" it onto 80-column punch cards that were then fed into the computer. When the author got back from vacation, I refrained from punching him in the face, and just yelled at him instead.
Nothing for 6-digit uids?
It boiled down to the fact that a data file was opened multiple times without being closed. NTFS would only allow one read/write access at a time, so subsuequent read/write fopen() calls would fail. The FAT filesystem did not have this problem, because it would happily allow you to open the same file multiple times.
Check out Chad's News
funny that you say that, because mozilla had a bug a lot like this--a dialog box wouldn't go away until you clicked the button _and_ moved the mouse by a pixel.
Liberty uber alles.
The packed decimal (80 bit extended) format used by the x87 (and others, I am sure) is just BCD, i.e. 4 bits per digit with 6 wasted values. There is no other reasonable way to store decimal in binary form (log2(10)~=3.322 bits) apart from... in binary!
Well, I suppose, 1024~=1000, so you could get 3 decimal digits per 10 bits. Or 6 in 20 bits. A quick play with my calculator shows 59 digits in 196 bits to be quite acceptable!
It would also be the reasoning of any other scientist. The reason the number gets rounded is because we are agreeing how many significant digits there will be. If we're rounding to the one's place, then the tenth's place is significant in terms of which direction we are going to round -- but we've already just admitted that we're only accurate to within a one's place (otherwise why would we round off there?). Therefore the hundredth's place is even MORE uncertain, and is ignored.
Mathematically it might be confusing, but with scientific measurements you just can't TRUST those small decimal places, so you pretend that they don't exist -- if the error is distributed symmetrically, the result is a "fair" rounding over many data points.
An infinte loop isn't quite as elegant as a single statement that wreaks havoc on your system, but it's still simple enough. In order to generate the "desired" result, you have to backspace beyond the first character of the terminal window, then output a printing character to the left of the beginning of the buffer. Apparently cmd.exe doesn't check for this condition, and triggers an error in a system-critical process.
I remember Microsoft bragging about how DOS programs run in their own virtual machine, so a mis-behaved DOS app can't crash your computer. I think this example here is proof-positive to the contrary.
If anybody has any more technical information about the cause (and possibly history) if this bug, I'd love to hear it.
What's it do? Oh, yeah, it reboots your computer. No shutdown, no warning. Just like hitting the power switch.
And aren't you glad you paid over $1000 for MS server software that can be rebooted by any user who executes a 4-character printf?
"With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea...."
RFC 1925
I found this bug in several commercial programs I've purchased in the past. I would install a program on my WinNT machine and discover it could only be run from an administrator account -- even though it wasn't doing anything that would normally require special access. The tech support people didn't seem to think this was much of a problem, but I go by the philosophy that my run-of-the-mill userid should not have adminstrator authority.
I tracked it down to the security settings for some of the registry keys. The call to open the key requested full access, which required administrator authority. Apparently the software had been developed and tested on Win9x or administator-level NT, where security does not really exist in the registry. The program did not require full access (read/write would be sufficient), but the coders probably didn't even bother with security.
The solution was to change the security level for a few registry keys. Once I did that, everything worked fine. I had to use a registry monitor to figure out what was happening.
Check out Chad's News
A friend of mine wrote this C++ code once:
// Some other code here
void SubClass::foo()
{
BaseClass:;foo();
}
It became an infinite loop... can you see why?
Mats
- 7^2
It would display something like this (the number of zeros is probably wrong):Check out Chad's News
I wrote an application for an introductory C++ class, and one of the assignments for it was to generate a data file to a certain spec, then swap data files with other classmates and run the second part of your program (a point-of-sale program using dynamic allocation and all of that nifty stuff....really basic for the Slashdot crew I'm sure.)
...and my program shit itself. Extra nodes in the list, off-by-1 (or off by more than 1) errors in the names, fields being swapped, etc.
I did my own test runs, and moved on to the next person's test runs...
I rewrote my ENTIRE input function AND my entire display function to try and figure out what was wrong with it.
Turns out, the kid who's file I got left out a single blank line after the first element. It read the first 2 fine, then glitched up, read a blank, and then read the fields at an offset that increased each time. By the 5th item, I was reading in random garbage from memory, it was so far off.
I just about killed the kid. Then I got someone else's data and used it instead.
My favorite is the bugs in the Tundra Universe/Universe II.
In the Tundra Universe, if multiple interrupts come in at different interrupt request levels, the response cycles can get confused. Therefore, applications can really only use one interrupt level.
In the Tundra Universe II, if more than four boards assert the same interrupt level at the same time, the responding board can not pull the signal high to acknowledge and the bus locks up. Therefore, applications must use different interrupt levels.
Therefore, you can't really mix Universe and Universe II chips in the same bus application.
When doing an rcp from source machine to target machine, if sum is run on the rcp source machine, the value would sometimes be incorrect. After the rcp finishes, the value is correct, there is no data corruption, and the file was transfered correctly to the target machine. If ftp was used, the problem did not occur.
It took over 6 months and 12 people to find the problem. The hardware was a uniprocessor MIPS R10k with non-coherent cache. The processor is capable of doing speculative execution which can dirty cache lines. The processor doesn't back out dirty bits when the speculative path falls back. So you can have a piece of code like:
if (foo) *bar = 1;
Even if foo is false, the speculative execution can cause the cachline containing bar to get marked dirty. Normally this doesn't cause a problem. However, if bar is used as a loop variable, and happens to point just past the end of a memory page, a cacheline for a subsequent page can be dirtied. If this page has an active DMA transfer in progress, then the first cacheline on that page can be overwritten with the dirty cacheline, corrupting the DMA data.
This was not a problem for userspace, since active DMA write pages were not mapped into userspace, but flipped in on completion of the DMA. In the kernel, the problem exists. The solution chosen at the time was to put a compiler workaround, which put a speculation stopping instruction at each conditional branch target. Since this compile switch was only used for the kernel, user binaries remained ABI compliant.
However, in "volatile" assembler portions of the kernel code (no compiler reordering permitted), this workaround had to be handcoded. After pouring through all the assembler by hand, no bugs were found. Finally a perl script was written which would check for store instructions lacking a speculation stopper. Some were found, and all discounted as harmless.
The problem turned out to be that the MIPS prefetch instruction allows you to pass a cache hint. There was a piece of checksum code that passed a write hint in a prefetch instruction. The fix turned out to be a 1 bit change: change the 7 prefetch code to a 3.
I have a DSP board from a company that shall remain unnamed. When you perform a DMA between the PC and the DSP board, the board's PCI controller is driving the board's external bus and nobody is refreshing the RAM. (All DRAM must be periodically refreshed, or the memory chip discharges). The hardware design team solved this problem in a particularly bad way. They assumed programmers would set up a DMA operation and then continuously poll the DMA status register until the transfer was complete. Thus, they configured a PLD to handle the refresh, as long as the PCI controller's DMA status register was being polled.
So what happens if you try to do an interrupt-driven DMA in the background? The system crashes because RAM isn't getting refreshed. The tech support person suggested a test: have one DSP chip do nothing but poll the PCI controller's DMA status register. Suddenly it worked fine. There is no way I could have figured this one out on my own. There was absolutely nothing wrong with my code, except that the hardware design engineers didn't expect anyone to use interrupt-driven DMA.
Fortunately this was a known issue and the company had an update, although we had to purchase a $150 cable so we could re-program the PLD.
Check out Chad's News
Its fairly useful when you want to assign the tokens to ptrs .. all ptrs will be null terminated without your intervention.
..
If you know what it does, and thats what you want, then its all good.
There are alternatives, no need to pick on an oldie but goodie
"Old man yells at systemd"
I discovered that the network concentrators at Uni would die on any sequence of 4 "n"s in a row (i.e. "nnnn") in the same packet. I was trying to read a man page and puzzled why the system kept dying before I got to the end. Eventually I redirected the man page to a file and used something like an octal dump to find the sequence without displaying it on the screen.
I then tested, typed "nnnn" and down went the network concentrator. Unfortunately that killed the other 15 users as well...
I reported this bug to the University Computer Centre who either didn't believe me or took no apparent action, but sometime later they upgraded to a different brand of gear for the campus WAN. I also reported it on comp.risks. I can find no other documented cases of this bug on the Net using a google search.
I used to be on UWaterloo's ACM programming contest team. More than once I got bitten by the ever-so-simple yet ever-so-annoying to debug 'missing return' phenomenon.
It seemed that on some architectures (eg. the local workstation I was testing on), the right value would just happen to be in the right register anyway. On the judges architecture (fortunately this was a local practice contest, not the world finals!) it failed one time out of one hundred. Yeah, yeah, I know, turn on warnings... it wouldn't fit with the contest mentality: vi + gcc and one terminal and you're set.
Wasted waaaay too much time on that one.
Round to even is not expensive, at least when you're talking about the binary computations in hardware that the IEEE routines address. In this case you just need a lookup table with your guard bits and the last significant digit. Even with 7 guard bits, that's a table with only 256 possible results (do nothing, decrement or increment). With RTE you may only need "do nothing" and "increment."
Of course, this is just the rounding performed by a single calculation. Most coprocessors use a few extra bytes over what they publish, e.g., the registers for a IEEE double (64 bits) will actually be 80 bits long.
For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
This is quite common with older games. Typically they will time a delay loop at initialization. (If the computer is very fast, the time taken will be zero.) Then a large number is divided by the time, to get a reasonable length for a delay loop inside the game. Have a fast computer? Expect division by zero!
1/2 = 0 looks perfectly normal to me, as opposed to 1.0/2 = 0.0 or 1/2.0 = 0.0 or 1.0/2.0 = 0.0 or...
Was having some really bizzare problems with our String class being used in a stl vector and ended up having to trace it into the RougeWave HP stl. It was in vector<_TypeT,_Allocator>::operator= (const vector<_TypeT,_Allocator>& __x)
// size() < _x.size() < capacity()
// advance this->end () first
// size() < _x.size() < capacity()
// advance this->end () first
// write past original value of this->end ()
below is the change for anyone who might have hit this or runs this setup. Hope it can help someone avoid it and all the time it wasted. Just love problems in the STL! *** are the two lines changed.
*** _C_end_of_storage = _C_finish = _C_start + __x.size();
}
else {
*** _C_end_of_storage = _C_finish = _C_start + __x.size ();
Changed To:
*** _C_finish = _C_start + __x.size();
}
else {
copy (__x.begin (), __x.begin () + size (), begin ());
uninitialized_copy (__x.begin () + size (), __x.end (),
begin () + size (),
_RWSTD_VALUE_ALLOC_CAST (*this));
}
*** _C_end_of_storage = _C_finish = _C_start + __x.size ();
This of course was becuase _C_end_of_storage should not have been set before the calling of size() as it would be incorrect.
Just Another Day For You and Me in Paradise.
Oh the times you wish people forgot to check "Post Anonymously"!
Anyway, our instructors were physics profs who focused on the hardware and never really put any effort into describing the instructions available on an 8080. We had been working at an extremely low level of logic design. At one point we had to write a program to add two numbers and display the results, and I actually wrote one looking something like
I was truly dreading doing multiplication and division, but fortunately someone pointed out the basic math opcodes first.
For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
Apparently I can't spell favorite right... Internal bug number #23456.
Just Another Day For You and Me in Paradise.
I have to say, I have read this thread slowly tonight, over many beers, and have posted many replies, and I have this warm fuzzy feeling, which may be due to the beers, but I rather feel that it is because the chaps at Microsoft were completely right in this instance. Furthermore, there has been a remarkable breakout of geekness, the kind of geek brotherhood (and sisterhood of course) that we truly share with our counterparts, who currently reside in the dungeons deep inside the Microsoft campus. I speak not of the fabled pointy headed creatures, but of the grunts, who art not so different from ourselves, if everything be considered.
Even though though this question was targeted towards devlopers (and I'm not a developer per se), my pet bug would have to be how Windows 2000 and Windows XP make my motherboard's power LED turn off in Linux.
Conspiracy, I say!
I believe you meant $cfff and $cf00...
??? I would say, rather, that it is good practice to use explicit casts (casts are not statements), if, and only if, implicit casts are not erm... explicit enough! Of course, as much as I like C++ (for example) implicit casts can get you into a lot of trouble if you don't have the entire ISO standard committed to memory. Fucked if I have...
I spent many hours when I was first learning C on this one:
/*b is the start of a comment.)
int divide(int *a, int *b)
{
return *a/*b;
}
(Hint:
Then there's the famous FORTRAN bug (if I can remember the syntax correctly):
CALL ADD(N,5)
SUBROUTINE ADD(I,J)
I=I+J
J=10
From then on, every time you used "5" you would actually get "10". (Call by reference or something from the dim past.)
Probabilistic primality tests are supposed to have a miniscule chance of declairing a composite number prime, and zero chance of declairing a prime number composite. I guess it's nice that the Java implementation errs on the side of safety, but it's silly that my Miller-Rabin test is faster and more accurate. The code I was sent works even faster. (The SRP people offered to email me some kind of proof of primality for the number. I'm not sure how that works, but thier code agrees with the stuff I coded up from Applied Crypto, so I'm pretty convinced Sun goofed.)
<OT>
Does anyone know a way to get a File object or an InputStream object for a file contained in a jar archive? This is my current reason for wanting to hurt the Java engineers. I'm trying to load an image out of a jar archive. The best solution I've come up with so far is to use Class.getResource(String) to get me a URL and then use java.awt.Toolkit.getImage(URL)
</OT>
Copyright Violation:"theft, piracy"::Anti-Trust Violation:"thermonuclear price terrorism"<-Overly dramatic language.
Here's one I just received in my email. Enjoy:
---
This is a real story happened between the customer of General Motors and its customer-care executive..
This complaint was received by the Pontiac Division of General Motors: This is the second time I Have written to you, and I don't blame you for not answering me, because I sounded crazy, but it is a fact that we have a tradition in our family of ice cream for dessert after dinner each night. But the kind of ice cream varies so, every night, after we've eaten, the whole family votes on which kind of ice cream we should have and I drive down to the store to get it. It's also a fact that I recently purchased a new Pontiac and since then my trips to the store have created a problem. You see, every time I buy a vanilla ice cream, when I start back from the store my car won't start. If I get any other kind of ice cream, the car starts just fine. I want you to know I'm serious about this question, no matter how silly it sounds: "What is there about a Pontiac that makes it not start when I get vanilla ice cream, and easy to start whenever I get any other kind?"
The Pontiac President was understandably skeptical about the letter, but sent an engineer to check it out anyway. The latter was surprised to be greeted by a successful, obviously well educated man in a fine neighborhood. He had arranged to meet the man just after dinner time, so the two hopped into the car and drove to the ice cream store. It was vanilla ice cream that night and, sure enough, after they came back to the car, it wouldn't start. The engineer returned for three more nights. The first night, they got chocolate. The car started. The second night, he got strawberry. The car started. The third night he ordered vanilla. The car failed to start. Now the engineer, being a logical man, refused to believe that this man's car was allergic to vanilla ice cream. He arranged, therefore, to continue his visits for as long as it took to solve the problem. And toward this end he began to take notes: he jotted down all sorts of data: time of day, type of gas uses, time to drive back and forth etc. In a short time, he had a clue: the man took less time to buy vanilla than any other flavor. Why? The answer was in the layout of the store. Vanilla, being the most popular flavor, was in a separate case at the front of the store for quick pickup. All the other flavors were kept in the back of the store at a different counter where it took considerably longer to check out the flavor.
Now, the question for the engineer was why the car wouldn't start when it took less time. Once time became problem - not the vanilla ice cream, the engineer quickly came up with the answer: "Vapor lock". It was happening every night; but the extra time taken to get the other flavors allowed the engine to cool down sufficiently to start. When the man got vanilla, the engine was still too hot for the vapor lock to dissipate.
Remember: Even crazy looking problems are sometimes real and all problems seem to be simple only when we find the solution with a cool thinking. Don't just say its "IMPOSSIBLE" without putting a sincere effort... Observe the word "IMPOSSIBLE" carefully... You can see "I'M POSSIBLE"... What really matters is your attitude and your perception.
The conversion from decimal to binary occurs in the library that interprets input (from a ASCII encoded file or the user at the console). The x87 does not handle BCD at all.
At this point forward, the number is represented internally by 80 consequetive bits in IEEE form. That is, sign bit, followed by 63 bits of mantissa and 16 bits of signed exponent. These are not BCD coded because they are not in base 10 anymore.
Furthermore, it would be foolish to store the number if BCD because of the inordinate amount of {stack, register, cache} space wasted, plus it helps to handle International number representation at the OS level (i.e. the French switch the comma and decimal point, group differently, etc.) thus freeing the application code from needing to worry about it.
Black holes are where the Matrix raised SIGFPE
About the time they went from LEDs to LCDs, there was a persistent bug in most TI handheld calculators - I seem to remember it into the 1980s - calculate 2^3, minus 8 and you didn't get zero - you got a very small decimal. Doh!
A check of many calculators today can give you some measure of internal accuracy - I use 123.456, take the square root, then square it. You get 123.456 - no surprise. Then do it sqrt twice, then sq twice, then three times each, and so on - many calculators can do seven down, then seven back up and still end up with 123.456 again. Some crap out after just two. I think the most I've seen is 11.
"Win treats sysadmins better than users. Mac treats users better than sysadmins. Linux treats everyone like sysadmins."
"Not enough memory to display error me"
Table-ized A.I.
Yeah, the one right under our noses: you browsing at 4 or 5? Click on the Threshold pulldown menu. What's it say? 35 Comments at 4+, 30 Comments at 5. But it also says -1,0,1,2 and 3 -scored posts add up to 35 each.
;)
So you can't guess how switching to a lower-scoring level will increase the html file coming down our modem pipes. Try it today
"Wireless : LAN
There's a similar story circulating, perhaps in the Jargon files. A guy gets a report that the system will allow the operators to log in when they're sitting at the console, but not when they're standing.
This makes no sense - there's absolutely no connection between the seat (or raised floor) and the system. How could it possibly know whether the person was standing or sitting?
The answer was in the keyboard. Somebody had dropped it and put the n and m keys back in the wrong place. While sitting, the operators could touch-type and they hit the right keys. But when standing, they had to look at the keys since they didn't have the muscle memory in this position to touch type. The two keys were in about the right place, they look similar, and nobody noticed that there was a problem with the keyboard.
The story has a fun personal touch since years before I heard about it I did the same thing with the office phone. We accidently dropped it, and as a joke I put the keys back in the standard calculator/keyboard layout, not the telephone layout. We all knew the numbers were reversed and could dial the right numbers, but one day a phone guy was in the office for some reason and got a very strange look on his face when he saw the phone. He insisted on "fixing" it.
For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
I recall using an 8086 with the (drumm roll) 8087 floating point accelerator chip (for those too young to remember, that was a separate chip you had the option to buy in early PCs if you wanted to do fast maths calulation. The Microsoft compiler of the time (v3or 4) had a bug that under some condition cause an underflow in the 8087 internal register stack on the 8th call (I think the internal hw stack had 8 entries). It took a real long time to find that, many weeks, I rang Microsoft and they said "Thanks!" and I never heard from them or got a work around. Some things never change...
:-)
I was helping a friend program their TV and found an error in the sequence of assigning frequencies to station numbers, it caused garbage to show where the nice green channel number was meant to be.
I remember writing a maze program on my trusty HP11C back in about '81 and I gave it to a friend. The bug cause the maze to be reflected on the x and y axes. I was trying out the program and got this creepy feeling as I wandered around the maze 4 times bigger than what the calculator had memory to handle. It was so weird. I took hours wandering around and eventually drew it out before seeing the pattern. Serendipity strikes
I wont mention the military system I worked on where the laser it fired (don't ask) would switch direction 180 degrees every time it crossed the Tropic of Capricorn (latitude 45 deg south). Or the bug in the artificial life breeding prgram that caused all offspring to remove their brains (controling code) when they were old enough to reproduce. Or the AI system that caused the 2D life to be attracted to a light but when the light was too close they spun in circles until they died - so weird to watch on the screen, very funny at the time.
pithy comment
My favourite bug from the VMS days is the one that reported, under certain conditions:
Warning: Hardware or software error.
... which was immensely useful, and narrowed the problem down to one of two things.
If you set a session variable in asp, it did not halt execution until that variable was actually set. That meaned that code like:
Session("MyVar") = "I did this"
Response.write Session("MyVar")
Might write the old value of Sesion("MyVar") or simply a blank.
Guess how strange bugs that could result in...
All opinions are my own - until criticized
unfinished: (adj.)
Sorry, the x87 can read and write BCD in hardware. Have a look at your x87 manual. Come back if you have any questions!
BCD is not foolish, if you are converting to/from decimal!
You don't terminate your strings in Power Dynamo - it's all written in Dynamo Script a sort of cludged up, crack-head designed version of server side Java. The entire thing is broken. Never, ever, use this product.
i once tracked an application problem down to code that appended to a buffer. if the buffer wasn't large enough, it would double its size before appending to it. if double wasn't enough, well, that's what you get for being greedy!
Everything should be made as simple as possible, but not simpler. -- A.E.
Well, sometimes you want to run a simulation that needs a random stream of number that is also entirely repeatable. For example, you want to rerun the sim after changing one parm or, err, fixing a bug :-)
But /dev/random does not spit the same sequence twice on command. So for simulation, an RNG with a seed is often the only choice.
Note that simulation people demand, in the same breath, absolute randomness and absolute repeatability. And then, we sim freaks wonder why real-world physicists won't take us seriously...
--
Mad science! Robots! Underwear! Cute girls! Full comic online! http://www.girlgeniusonline.com/