eli5: Why do bugs in software exist?

327 views

eli5: Why do bugs in software exist?

In: 0

9 Answers

Anonymous 0 Comments

Because it’s seriously complicated to work out everything that even a very simple system equence of statements is actually capable of doing. And people are fallible, and will make errors. And there’s ALWAYS a budget of some sort, so there’s limited time to do what you have to, and limited time for you and others to attempt to check that you did. The best you can hope is that you caught all the worst stuff.

**Classic real example: IEFBR14**

The first version of IEFBR14, the “shortest possible program” for the IBM OS/360 operating system – whose job is, effectively, “do nothing, and finish”, one instruction in IBM assembly language – had a bug.

The operating system conventions say that, before a program is called, a return address (where to find the code to run after the program has done) has to be placed in a place in memory called “register 14”. So all the program has to do, when it’s done whatever it’s supposed to do, is a single instruction to pass control to the next piece of code. In IBM assembly language, the instruction is the four characters “BR14”, meaning “branch on Register 14 (hence part of the program name). And when all the program has to do is one instruction, and you know exactly what that instruction is, you’d think it couldn’t go wrong. That’s all that IEFBR14 needed to do, so that’s all it did.

Except.

Another operating system convention says that, before a program returns, it should tell the operating system whether or not it thinks that it finished successfully, by putting a number in another place in memory. Zero if it finished OK, something else if it didn’t. And the programmer forgot that, so IEFBR14 didn’t do it. So, actually, even though its job was to “do nothing”, the program still had housekeeping stuff to do that the operating system needed. So – not actually nothing. And because it didn’t set that number, the code that followed would look in memory to see how IEFBR14 got on, and see whatever happened to be in the memory location at the time – which could be anything. And then it would act on that value. So sometimes it worked, but often it didn’t. So the program had to be updated to put a zero into the right piece of memory.

That wasn’t even the last bug. I can’t remember all the fine detail, but I seem to remember that there were two or three other, similar things at least that needed to be “corrected” before the code was finally deemed bug-free.

(Why you’d want a program that “does nothing” is a different topic. It sounds absurd, but in context, it’s actually very useful.)

You are viewing 1 out of 9 answers, click here to view all answers.