TL;DR
While I am writing this post, my Mac handles a dozen interrupts. Let’s explain what interrupts are and which software bugs are related to interrupts. The post is aligned with the Black Box Software Testing Foundations course (BBST) designed by Rebecca Fiedler, Cem Kaner, and James Bach.
The interrupt is programming control that enables an operating system to communicate with a program in execution at any time. We have:
- hardware interrupts
- software interrupts.
Source of hardware interrupt is a hardware device, such as the keyboard, mouse, Bluetooth. The source of the software interrupt is a program. An example is an operating system. CTRL + C is the most famous hardware interrupt that enables us to stop a program that is no more responding to any other user input.
When a program receives an interrupt, it saves its current state and runs code that handles received interrupt.
The most common usage of interrupts is computer multitasking or informing programs about significant environmental changes through hardware devices.
Examples
Keypress on a computer keyboard.
The printer paper tray is empty.
A sound alarm is triggered by a cat.
Disk Drive driver reports I/O error.
Common Bugs
Deadlock
This is the most famous bug in multitasking operating systems. Program A interrupts program B and waits for it to finish handling this interrupt. Program B handles interrupt from program A and in interrupt handler waits for program A to finish.
Stack Overflow
When a program receives an interrupt, it stores the current state in a particular memory location called Stack. As this memory has limited capacity, the current program state could not be stored on stack due to a lack of free space. This is called stack overflow.
Race Condition
Hacker uses this bug to get into the programs by triggering program interrupts. Imagine the login feature. You tested for happy and alternative paths. But what would happen if the backend server receives an interrupt IO error while the user credentials check is currently in progress? What if there is no interrupt handler on the backend server and server falls to part of a program that accepts any user credentials without checking? This is a race condition.
In the previous post, we explained exception control. During the teaching BBST foundations course, I found that students have trouble distinguishing exception from interrupt.
Printer receives page margin that is out of its limmits and reports this error to Adobe Photoshop. Is this interrupt or exception?