FOUNDING PRICING · 40% OFFfor the first 1,000 members · from ₹95/month
OutageArianespace / ESA11 min read

Ariane 5 Flight 501: The Integer Overflow That Lost a Rocket

How a 64-bit float squeezed into a 16-bit integer shut down both guidance units on the first Ariane 5 in 1996, and what the inquiry said went wrong.

ShareXLinkedInWhatsApp
A later Ariane 5 rocket lifting off at night from its launch pad at Kourou in 2013, lit by its own exhaust, with clouds of smoke spreading across the ground.
A later Ariane 5 rocket lifting off at night from its launch pad at Kourou in 2013, lit by its own exhaust, with clouds of smoke spreading across the ground. Photo: DLR German Aerospace Center, CC BY 2.0, via Wikimedia Commons.

On 4 June 1996 the first Ariane 5 left its pad at Kourou in French Guiana, flew normally for about half a minute, then turned sharply, broke apart and destroyed itself. The inquiry traced the loss to one line of reused software that converted a 64-bit floating point number into a 16-bit signed integer and received a value too large to fit. Nothing was physically wrong with the rocket. Every later step followed from how the software was told to react to that one error.

The Inquiry Board's report is public and unusually frank, which makes this a compact lesson in number representation, exception handling and why two copies of the same program are not a backup for each other.

A flow diagram of the failure chain on Ariane 5 flight 501: the variable BH is converted from a 64-bit float to a 16-bit signed integer, the conversion raises an Operand Error, the back-up and then the active inertial reference system shut down, the active unit puts a diagnostic bit pattern on the databus, the on-board computer reads it as flight data and commands full nozzle deflection, and the launcher breaks up and self-destructs.

What happened on the day

Flight 501 was a test flight with no crew. Its payload was the four satellites of ESA's Cluster science mission. The countdown was held seven minutes before ignition because visibility at the site was not yet good enough, and resumed once it improved.

The report measures time from H0, the command to ignite the main engine. Lift-off comes roughly seven seconds after H0, so "37 seconds after H0" and "about 30 seconds after lift-off" describe the same moment.

TimeWhat happened
H0 minus 3 sThe two inertial reference systems switch to flight mode.
H0 (09:33:59 local, 12:33:59 UT)Main engine ignition is commanded. Ignition and lift-off are normal.
H0 + 36 sLast moment of normal behaviour.
H0 + 36.7 sThe back-up inertial reference system stops working.
About 0.05 s laterThe active inertial reference system stops for the same reason.
Next momentsThe nozzles of both solid boosters, and then of the main engine, swing to their extreme positions.
H0 + 39 sThe launcher starts to break up under aerodynamic load. The self-destruct system fires.

The break-up happened at an altitude of roughly 4 km, about 1 km from the pad. The debris fell over mangrove swamp and savanna east of the launch site, which made recovery slow. Both inertial reference units were found, and their memory was read out, which is why the cause is known so exactly.

An Ariane 5 rocket standing upright on its mobile launch table beside a tall mast, being moved along a track towards the launch zone at the Guiana Space Centre.
A later Ariane 5 being rolled out to the launch zone at Kourou in 2011. The two solid boosters on either side and the central main engine all have steerable nozzles. Photo: elisabetta_monaco, CC BY 2.0, via Wikimedia Commons.

How Ariane 5 knows where it is pointing

A launcher has no outside reference in the first minutes of flight. It works out its attitude and motion from an inertial reference system, called SRI after its French name. Each SRI contains laser gyroscopes and accelerometers and its own computer, which turns the raw sensor readings into angles and velocities.

The SRI sends this data over a databus to the On-Board Computer (OBC). The OBC runs the flight program and steers by swivelling the nozzles of the two solid boosters and of the Vulcain main engine through hydraulic actuators.

Because losing attitude data means losing the vehicle, there were two SRIs. One was active and the other ran in hot stand-by, doing the same work in parallel. If the OBC saw the active unit fail, it would switch at once to the other. The two units had identical hardware and identical software.

The report also says the Ariane 5 SRI was practically the same as the one flying on Ariane 4, especially in its software.

The root cause: a 64-bit float into a 16-bit integer

Before lift-off, the SRI runs an alignment function. With the rocket standing still at a known position, it finds the direction of gravity and of north. One of the values it computes along the way is called BH, for horizontal bias. BH is related to the horizontal velocity that the platform senses.

BH was held as a 64-bit floating point number. At one point the code converted it into a 16-bit signed integer. A 16-bit signed integer can hold only the whole numbers from -32,768 to 32,767. A 64-bit float can hold values vastly larger than that. So the conversion is only safe if something else guarantees the value stays small.

On Ariane 4 something did. Its trajectory in the first 40 seconds was such that the value could not reach the limit. Ariane 5 accelerates harder and follows a different early path, and the report says its horizontal velocity builds up five times more rapidly. On flight 501, BH grew past what 16 bits can hold. The exact value is not given in the public report.

The software was written in Ada, and the failed conversion raised what the report calls an Operand Error. In outline, the difference between a guarded and an unguarded conversion looks like this (an illustration, not the flight code):

-- Guarded: check the range before narrowing
if X > 32767.0 or X < -32768.0 then
   Handle_Out_Of_Range;
else
   N := Integer_16 (X);
end if;

-- Unguarded: trusts that the value always fits
H := Integer_16 (BH);   -- raises an error when BH is too large
A diagram comparing the two number types: a wide bar for a 64-bit float that can hold very large values and a short bar for a 16-bit signed integer limited to the range minus 32,768 to 32,767, with the Ariane 4 value of BH inside the range and the Ariane 5 value outside it, and a note that four of seven at-risk conversions were guarded and three, including BH, were not.
Why the conversion failed: the destination type is far smaller than the source

Why one exception stopped both computers

An arithmetic error in a monitoring value should not be able to destroy a rocket. Three design decisions turned it into one.

The conversion was left unguarded on purpose. The developers had analysed every operation that could raise an exception. Seven float-to-integer conversions were at risk. Four were given protection. Three, including BH, were not, because the reasoning at the time was that those values were physically limited or had a large margin. The report links this to a target that the SRI computer should run at no more than 80% of its capacity. It was never rechecked against the Ariane 5 trajectory, and it was not written down in the source code where a reviewer might have found it.

Any exception meant shutting the processor down. The specification said that on any exception the SRI should report a failure on the databus, save the failure context to EEPROM memory and stop its processor. The Board explains the thinking: the programme treated errors as random hardware faults. If a chip fails in one unit, switching it off and handing over to the healthy twin is exactly right.

The twin ran the same software. A software design error is not random. Given the same inputs, an identical program fails identically. The back-up SRI met the same value and shut down first. The active one followed about 0.05 seconds later, in the next 72 millisecond data cycle. When the OBC looked for a unit to switch to, there was none.

Then came the final step. The stopped active SRI was no longer sending attitude data. What it put on the bus was a diagnostic bit pattern. The OBC interpreted those bits as flight data, concluded the rocket was far off its intended attitude, and commanded full nozzle deflection to correct a deviation that did not exist. The resulting angle of attack was more than 20 degrees. The aerodynamic load tore the boosters from the core stage, and that triggered the self-destruct system, as designed.

Code that had no reason to be running

The alignment function does nothing useful once the rocket has left the ground. Its results only make sense while the launcher is stationary.

It was still running because of an Ariane 4 requirement that was more than ten years old. On Ariane 4, if the countdown was held in the last few seconds, a full realignment would take 45 minutes or more and the launch window might be lost. So the alignment software was kept running for 50 seconds after the SRI entered flight mode, allowing a quick restart. The report notes this feature was used once, in 1989.

Ariane 5 has a different preparation sequence and did not need it. The requirement was kept anyway for commonality, on the view that software which works should not be changed without need. On Ariane 5, flight mode starts at H0 minus 3 seconds, so the function ran through roughly the first 40 seconds of flight.

A timeline from H0 minus 3 seconds to H0 plus 47 seconds showing the alignment function running for the full 50 seconds after flight mode starts, lift-off at about H0 plus 7 seconds, the failure of both inertial reference systems at H0 plus 36.7 seconds and the break-up at H0 plus 39 seconds, with a note that the function is only useful before lift-off.
The alignment function kept running for about 40 seconds of flight

The Board found that the failure could have been caught on the ground, and names the gaps.

  • The trajectory was not in the specification. The partners had jointly agreed not to include Ariane 5 trajectory data in the SRI requirements. With no such requirement, nobody tested the SRI against the Ariane 5 countdown and flight profile.
  • The system simulations used simulated SRIs. At the Functional Simulation Facility, many closed-loop simulations of the whole flight were run with real equipment in the loop, but the two SRIs were replaced by software models. The original plan had been to include real units. That was dropped in 1992, partly because the SRI was regarded as already qualified.
  • The limitation was not declared. Nothing in the SRI's documentation said that it only worked within a certain range of horizontal velocity.
  • Reviews did not find it. The Board calls the review process a contributory factor, because the limits of the alignment software and of the test coverage were not understood.

After the accident, simulations using the real SRI software and the actual flight trajectory reproduced the failure faithfully.

A blackened and partly melted box-shaped metal component resting on a torn sheet of carbon fibre in a display case, with a small label reading support strut of the satellite structure.
A recovered support strut of the satellite structure from flight 501, on display. Photo: Deadpan, public domain, via Wikimedia Commons.

The report ends with fourteen recommendations. The ones most relevant to software engineers are these.

  • Switch off the alignment function immediately after lift-off, and more generally run no software function in flight unless it is needed.
  • Build a test facility with as much real equipment as possible, feed it realistic inputs and run complete closed-loop tests before any mission.
  • Do not let sensors such as the SRI stop sending data. They should keep supplying their best estimate.
  • Review all flight software for implicit assumptions, and check the range of every internal variable.
  • Confine exceptions to the task that raised them where possible, and provide back-up capability.
  • Put trajectory data into the specifications and test requirements.

ESA's statement on the report said the programme would correct the SRI problem, re-examine all software embedded in equipment and make the qualification test environment more representative of the real launcher. The Cluster mission was rebuilt as Cluster II and launched in two pairs in July and August 2000.

The computer science underneath

Fixed-width integers and narrowing conversions. An n-bit signed integer in two's complement holds values from -2^(n-1) to 2^(n-1) - 1, so 16 bits gives -32,768 to 32,767. The lesson on the bit manipulation toolkit covers two's complement and where the limits come from. Converting from a wider type to a narrower one is called narrowing, and languages disagree about what happens when the value does not fit. Ada raises an error. Java clamps a float to the limits of int. In C, converting an out-of-range floating point value to an integer is undefined behaviour. None of these is safe by default: you must know the range of your input.

What an exception handler is for. Detecting an error is half the job. The other half is deciding what the system should do next. The lesson on exceptions in object-oriented code explains how an exception travels up until something handles it. Here the handler of last resort was "stop the processor", a policy designed for broken hardware and applied to a software error in a value that no longer mattered.

Reused code carries hidden preconditions. The conversion had an unwritten precondition: BH stays within 16 bits. That held for Ariane 4 and was silently broken by Ariane 5. Design by contract is the discipline of stating such preconditions explicitly, so that a new caller in a new environment can be checked against them.

Redundancy only covers independent failures. A hot stand-by protects against faults that hit one unit and not the other. The same idea appears in databases as replication and failover: a replica saves you from a dead disk, but a bad query or corrupt write replicates faithfully. The complementary idea is graceful degradation: keep a failure small and keep serving a reduced answer, which is what the Board meant by best-effort data.

What an interviewer could ask from this

What is the range of a 16-bit signed integer, and why is it not symmetric? -32,768 to 32,767. Two's complement has 2^16 bit patterns; half have the top bit set and are negative, and zero takes one of the non-negative patterns.

Strictly, was this an integer overflow? It was an overflow during a narrowing conversion from floating point to integer, not from integer arithmetic such as adding two ints. The effect is the same: the result cannot be represented in the destination type.

Both computers failed. Does that mean redundancy is useless? No. Identical redundancy handles random hardware faults well. It does nothing for a design error, because both copies share it. Covering that needs diversity, range checks or a degraded mode.

The exception was detected. Why was the outcome still fatal? Because the response was wrong for the situation. Shutting down discarded a working sensor over an error in a value that was not needed in flight, and the consumer then misread diagnostic output as data.

How would you have tested for this? Feed the real unit, not a model of it, with inputs taken from the real mission profile. Add tests at the boundaries of every narrowing conversion.

Takeaways

  • A value that always fitted in 16 bits on one rocket did not fit on the next. Reused software brings its old assumptions with it.
  • An unguarded narrowing conversion is a bet about the range of the input. Write the bet down and test it.
  • Duplicating identical software protects against hardware faults, not against bugs.
  • The error handler is part of the design. "Shut down" is only safe when something else can take over.
  • Code that is not needed should not be running, and a subsystem should be tested with the inputs it will really see.

Sources

  1. Ariane 5 Flight 501 Failure: Report by the Inquiry Board (chairman Prof. J. L. Lions), 19 July 1996
  2. ESA press release: Ariane 501, Presentation of Inquiry Board report
  3. ESA press release: Cluster II nears countdown
  4. ESA: Cluster overview

Written by the Codevizag Academy team

An independent explainer built from the public sources listed above. Codevizag Academy is not affiliated with Arianespace / ESA. Found a mistake? Write to support@codevizag.com.

More case studies

Understood it? Now prove it.

The lessons behind this case study are free, and 20 problems a month are judged on real test cases at no cost.

Start solving free