Real-world case: The update that supplied 20 values where 21 were expected
19 July 2024 · Security software on Windows computers
A security company regularly sent small configuration updates, called Rapid Response Content, to the sensor program on its customers' Windows computers. In February 2024 it added a new kind of check that was defined to use 21 input fields, but the sensor code that fed the checks supplied only 20 values.
For months nothing went wrong, because the checks sent out never used the 21st field. On 19 July 2024 a new update did. The program tried to read a 21st value that did not exist, read beyond the end of its input list, and crashed the computer. The company's own validation step had passed the update because of a logic error in how it checked the inputs.
About 8.5 million Windows devices were affected, causing disruption at hospitals, airlines and other organisations. The company published a detailed root cause analysis on 6 August 2024 and added checks on the number of fields, bounds checking when reading the list, and staged releases.
How the case shows what you learned in this module
| Module idea | In the case |
|---|---|
| A mismatch between two parts | One part was written for 21 inputs and the other supplied 20, and no test caught it. |
| Out-of-bounds read | Reading past the end of a list is the same fault as an IndexError in Python, but with a crash of the whole machine. |
| A validator that was itself wrong | A check can pass bad data if the check has a fault. |
| Staged release is a test too | Sending an update to everyone at once gave no chance to catch the fault on a few machines first. |
Workplace takeaway. Test each part with the number and kind of inputs it will really receive, check bounds before reading, and release in stages so one fault cannot reach everyone at once.
Sources: CrowdStrike, External Technical Root Cause Analysis: Channel File 291 (6 August 2024) and Executive Summary; TechTarget, CrowdStrike details errors that led to mass IT outage (August 2024); Help Net Security (August 2024)
Discussion prompt
20 minutes. Think of a program, spreadsheet or process in your work that has failed or given a wrong answer. In 150 to 200 words, say how you would reproduce it, which test case you would keep, and which expected failure you would handle rather than let stop the program.
Private: nothing you type here is sent or stored.
This course has no discussion board yet, so the prompt is a private reflection.
Recap
- Read tracebacks from the bottom and learn the common error names.
- Use try and a named except for expected failures; never hide mistakes with a bare except.
- Test with answers worked out by hand, including boundaries and odd inputs.
- Debug by method: reproduce, narrow, change one thing, retest, keep a test.
Flashcards: 12 workplace review cards
Tap a card to reveal the answer. Read the question, answer it aloud or in writing first, then check yourself against the explanation.
Card 1 of 12 · How do you read a traceback?
From the bottom. The last line names the error and gives a reason; the line above shows the code and its line number. Start there.
Card 2 of 12 · What is a SyntaxError?
The code is not valid Python, such as a missing bracket or colon. It is found before the program runs.
Card 3 of 12 · What is a NameError?
Python cannot find a name, often because it is misspelled or was made inside a function. Check the spelling and the scope.
Card 4 of 12 · What is a TypeError or a ValueError?
TypeError: the wrong kind of value, such as adding text to a number. ValueError: the right kind but unusable, such as int("abc").
Card 5 of 12 · What are IndexError and KeyError?
IndexError: a list position that does not exist. KeyError: a dictionary key that is not present. Check with len or in before using it.
Card 6 of 12 · Why is a wrong answer with no error the worst fault?
Nothing warns you, so the wrong total is used. Only testing against a known answer reveals it. Check results as well as crashes.
Card 7 of 12 · What do try and except do?
try runs a risky step; except handles a named error if it happens, so the program can continue safely. Use it for a text entry where a number is needed.
Card 8 of 12 · Why should you never use a bare except?
It catches every error, including your own mistakes, and hides them. A loud failure becomes a quiet wrong answer.
Card 9 of 12 · What is a test?
Run the code on an input whose answer you worked out by hand, then compare. grade(70) should be A; if it is not, the test fails.
Card 10 of 12 · What is an edge case?
A boundary or odd input: 49 and 50 for a pass mark of 50, zero, or an empty list. Faults hide at edges.
Card 11 of 12 · What are the steps of debugging?
Reproduce the fault, narrow it down, change one thing, retest everything, and keep a test. A method beats guessing.
Card 12 of 12 · Why change only one thing at a time?
If you change several things and the fault goes, you do not know which change worked, and you may have added a new fault. One change, then retest.
Module notes
Key terms. Traceback: the report Python prints when it stops. Exception: an error raised at run time. try / except: run a risky step and handle a named error. assert: check a statement and raise AssertionError if false. Edge case: a boundary or unusual input. Debugging: finding and fixing the cause of a fault. Regression test: a test kept so an old fault cannot return.
Rules and formulas. expected answer first, then run, then compare; one change at a time; name the error you catch.
Limits of this module. Examples use Python 3 and small programs. Larger projects use test tools and debuggers, but the thinking is the same. Run each example to confirm the output shown.
Next
Continue to Module 8: Your Useful Program: Design, Test and Explain. You can also return to the course overview or the University Track.
References and further reading
- Python Software Foundation. The Python Tutorial and The Python Language Reference (documentation for Python 3), available from python.org.
- Specialty Digest encyclopedia: Programming Language, Algorithm, Object-Oriented Programming and Binary Search.