<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Senthil Kumaran (Posts about bugs)</title><link>http://senthil.learntosolveit.com/</link><description></description><atom:link href="http://senthil.learntosolveit.com/categories/bugs.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sat, 29 Aug 2026 22:04:36 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Nuclear Gandhi in Civilization V</title><link>http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html</link><dc:creator>Senthil Kumaran</dc:creator><description>&lt;p&gt;It seems like the developers of Civilization V once decided to store aggresiveness index of leaders in a unsigned int.
And Gandhi, as the most pacifist leader that he was, was assigned lowest number 1. Also, in the game play if a society adopted
democracy, the aggresiveness score was reduced by 2.&lt;/p&gt;
&lt;p&gt;So, when Gandhi adopted democracy, his aggresiveness score became &lt;strong&gt;1 - 2 = -1&lt;/strong&gt;, and as it was unsigned int, and it gained a very high value.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code c"&gt;&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-1" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-1" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-1"&gt;&lt;/a&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-2" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-2" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-3" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-3" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-3"&gt;&lt;/a&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-4" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-4" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-5" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-5" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-6" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-6" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%x&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a id="rest_code_d286ca493a9a4c8d9543deddaf0f8846-7" name="rest_code_d286ca493a9a4c8d9543deddaf0f8846-7" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_d286ca493a9a4c8d9543deddaf0f8846-7"&gt;&lt;/a&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_e808490843664311acb02d0f39239196-1" name="rest_code_e808490843664311acb02d0f39239196-1" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_e808490843664311acb02d0f39239196-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;clang&lt;span class="w"&gt; &lt;/span&gt;unsigned.c
&lt;a id="rest_code_e808490843664311acb02d0f39239196-2" name="rest_code_e808490843664311acb02d0f39239196-2" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_e808490843664311acb02d0f39239196-2"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;./a.out
&lt;a id="rest_code_e808490843664311acb02d0f39239196-3" name="rest_code_e808490843664311acb02d0f39239196-3" href="http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html#rest_code_e808490843664311acb02d0f39239196-3"&gt;&lt;/a&gt;&lt;span class="m"&gt;4294967295&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And thus Gandhi was ready to nuke whenever there is a conflict.&lt;/p&gt;</description><category>bugs</category><guid>http://senthil.learntosolveit.com/posts/2017/10/21/nuclear-gandhi-in-civilization-v.html</guid><pubDate>Sat, 21 Oct 2017 18:44:00 GMT</pubDate></item><item><title>Computer Bugs - Roundoff Error and the Patriot Missile</title><link>http://senthil.learntosolveit.com/posts/2017/07/17/computer-bugs-roundoff-error-and-the-patriot-missile.html</link><dc:creator>Senthil Kumaran</dc:creator><description>&lt;section id="section-1"&gt;
&lt;h2&gt;0.10&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;During the Gulf War in 1991, a U.S. Patriot missile failed to intercept an&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iraqi Scud missile, and 28 Americans were killed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A later study determined that the problem was caused by the inaccuracy of the binary representation of 0.10.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Patriot incremented a counter once every 0.10 seconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It multiplied the counter value by 0.10 to compute the actual time. However, the (24-bit) binary representation of 0.10 actually corresponds to 0.099999904632568359375, which is off by 0.000000095367431640625.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This doesn’t seem like much, but after 100 hours the time ends up being off by 0.34 seconds—enough time for a Scud to travel 500 meters!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Professor Skeel wrote a &lt;a class="reference external" href="http://mate.uprh.edu/~pnegron/notas4061/patriot.htm"&gt;short article&lt;/a&gt; about this.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;</description><category>bugs</category><guid>http://senthil.learntosolveit.com/posts/2017/07/17/computer-bugs-roundoff-error-and-the-patriot-missile.html</guid><pubDate>Mon, 17 Jul 2017 16:09:13 GMT</pubDate></item><item><title>Ariane 5 Flight 501</title><link>http://senthil.learntosolveit.com/posts/2008/09/24/ariane-5-flight-501.html</link><dc:creator>Senthil Kumaran</dc:creator><description>&lt;p&gt;While listening to an introductory programming class, came across the mention of this this "
        &lt;span class="wikipedia_tooltip"&gt;&lt;a href="https://en.wikipedia.org/wiki/Ariane_flight_V88" target="_blank"&gt;Ariane_5_Flight_501&lt;/a&gt;
            &lt;span class="wikipedia_summary"&gt;
            &lt;a href="https://en.wikipedia.org/wiki/Ariane_flight_V88" target="_blank" class="wikipedia_wordmark"&gt;
              &lt;img src="https://upload.wikimedia.org/wikipedia/commons/b/bb/Wikipedia_wordmark.svg"&gt;
              &lt;span class="wikipedia_icon"&gt;&lt;/span&gt;
            &lt;/a&gt;
            Ariane flight V88, also known as Ariane 5 Flight 501, was the failed maiden flight of the Arianespace Ariane 5 rocket, vehicle no. 501, on 4 June 1996. It carried the Cluster spacecraft, a constellation of four European Space Agency research satellites.
            &lt;/span&gt;
        &lt;/span&gt;" failure incident, which was caused by Arithmetic Exception and Integer overflow resulted from automatic type casting float to integer in the ADA program. Very costly software bug.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www-aix.gsi.de/~giese/swr/ariane5.html"&gt;This German article&lt;/a&gt; discusses the issue. Below is the English translation of the same with the help of translate.google.com with &lt;em&gt;some comments&lt;/em&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Ariane 5 - 501 (1-3) Ariane 5 - 501 (1-3)&lt;/p&gt;
&lt;p&gt;4th June 1996, Kourou / FRZ. Guyana, ESA Guyana, ESA&lt;/p&gt;
&lt;p&gt;Maiden flight of the new European launcher (weight: 740 tons, payload 7-18 t) with 4 Cluster satellites&lt;/p&gt;
&lt;p&gt;Development costs in 10 years: DM 11 800 million &lt;em&gt;I am not sure about 11 space 800 million. If it is, then its 4 trillion Rupees roughly.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ada program of the inertial navigation system (excerpt):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;declare&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;vertical_veloc_sensor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;float&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_sensor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;float&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;vertical_veloc_bias&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_bias&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;begin&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;declare&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;pragma&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;suppress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numeric_error&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_bias&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;sensor_get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertical_veloc_sensor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;sensor_get&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_sensor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;vertical_veloc_bias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertical_veloc_sensor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_bias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;horizontal_veloc_sensor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;exception&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;exceptionnelle&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;When&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;numeric_error&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calculate_vertical_veloc&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;others&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;use_irs1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;irs2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Effect:&lt;/p&gt;
&lt;p&gt;37 seconds after ignition of the rocket (30 seconds after Liftoff) Ariane 5 reached 3700 m in altitude with a horizontal velocity of 32768.0 (internal units). This value was about five times higher than that of Ariane 4th&lt;/p&gt;
&lt;p&gt;The transformation into a whole number led to an overflow, but was not caught.&lt;/p&gt;
&lt;p&gt;The replacement computer (redundancy!) Had the same problem 72 msec before and immediately switched from &lt;em&gt;that&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;This resulted in that diagnostic data to the main computer were sent to this interpreted as trajectory data. Consequently, nonsensical control commands to the side, pivoting solid engines, and later to the main engine, to the deviate Flight no large (over 20 degrees) to correct them.&lt;/p&gt;
&lt;p&gt;The rocket, however, threatened damage control and tested all himself (39 sec). &lt;em&gt;I guess auto-destruct.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;An intensive test of the navigation and main computer had not been undertaken since the software was in tested Ariane 4.&lt;/p&gt;
&lt;p&gt;Damage:
- DM 250 million start-up costs (&lt;em&gt;~ 8.5 billion INR&lt;/em&gt;)
- DM 850 million Cluster satellites (&lt;em&gt;~ 29 billion INR&lt;/em&gt;)
- DM 600 million for future improvements (&lt;em&gt;~ 20 billion INR&lt;/em&gt;)
- Loss of earnings for 2 to 3 years&lt;/p&gt;
&lt;p&gt;The next test flight was only 17 months later carried out - 1 Stage ended prematurely firing.&lt;/p&gt;
&lt;p&gt;The first commercial flight took place in December 1999.&lt;/p&gt;
&lt;p&gt;Tragedy:&lt;/p&gt;
&lt;p&gt;The problematic part of the program was only in preparation for the launch and the launch itself needed.&lt;/p&gt;
&lt;p&gt;It should only be a transitional period to be active, for security reasons: 50 sec, to the ground station at a launch control over the interruption would have.&lt;/p&gt;
&lt;p&gt;Despite the very different behavior of the Ariane 5 was nothing new about value.&lt;/p&gt;
&lt;p&gt;Optimization:&lt;/p&gt;
&lt;p&gt;Only 3 of 7 for a variables overflow examined - for the other 4 variables evidence existed that the values would remain small enough (Ariane 4).&lt;/p&gt;
&lt;p&gt;This evidence was not for the Ariane 5 and this was not even understood.
Problem was with the of reuse of software!&lt;/p&gt;
&lt;p&gt;Incredible - after 40 years of software-defect findings:&lt;/p&gt;
&lt;p&gt;It was during program design assumes that only hardware failure may occur!
Therefore, the replacement computers also identical software. The system specification established that in case of failure of the computer is off and the replacement computer einspringt. A restart of a computer was not useful, since the redefinition of the flying height is too expensive.&lt;/p&gt;
&lt;p&gt;PS: The attempt to establish new 4 Cluster satellites to launch, succeeded in July and August 2000 with two Russian launchers.&lt;/p&gt;
&lt;hr&gt;</description><category>ada</category><category>bugs</category><category>programming</category><category>software</category><category>spacecraft</category><guid>http://senthil.learntosolveit.com/posts/2008/09/24/ariane-5-flight-501.html</guid><pubDate>Wed, 24 Sep 2008 18:02:00 GMT</pubDate></item></channel></rss>