In engineering, a bug is a defect in the design, manufacture or operation of machinery, circuitry, electronics, hardware, or software that produces undesired results or impedes operation. It is contrasted with a glitch which may only be transient. Sometimes what might be seen as unintended or defective operation can be seen as an feature.
In software, a bug is a system behaving in a way that is unpredictable, or just not part of what the designer wanted. According to legend, the first bug was actually a bug, that was found inside of a circuit board and caused the system to fail. A running joke between programmers is that a given fault is not really a bug, but rather a feature.