From a computer engineering point of view, safety-critical systems are usually double or triple-redundancy. I believe in the airbus there are three control systems, each with a different type of processor and different software, although they are following the same algorithm. (My references are at work, or I would give a citation). The three different systems preclude the possibility of a virus or silicon mask fault from causing a failure in all three systems.
The actual algorithm is tested to the nth degree, and its implementation checked by the contractors for the three computers and airbus.
However, there is always the possibility that one or two systems may fail in a way that makes it look like the third system has failed,when in fact it is the only one working. This is called a Byzantine failure, after the difficulty associated with figuring out which of the Byzantine Generals is loyal and will attack an enemy. It is the computer engineer's worst nightmare, and a good reason to have two well-qualified and experienced pilots at the front of the bus!