<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>&#62;kloctalk&#187; Nasty Bugs</title>
	<atom:link href="http://www.klocwork.com/blog/category/nasty-bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klocwork.com/blog</link>
	<description>&#62;kloctalk is a blog and a community for software development professionals who create and maintain mission-critical software and the challenges they face on a daily basis.</description>
	<lastBuildDate>Tue, 27 Jul 2010 15:00:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Google offers cash reward for finding bugs in Chrome</title>
		<link>http://www.klocwork.com/blog/2010/02/google-offers-cash-reward-for-finding-bugs-in-chrome/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=google-offers-cash-reward-for-finding-bugs-in-chrome</link>
		<comments>http://www.klocwork.com/blog/2010/02/google-offers-cash-reward-for-finding-bugs-in-chrome/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 20:23:58 +0000</pubDate>
		<dc:creator>Eric Hollebone</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[google chrome]]></category>
		<category><![CDATA[software security]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=814</guid>
		<description><![CDATA[As Google Chrome climbs out of obscurity in the browser market and expands into a light-weight but fully functional OS, security seems to have become a top of mind issue over at chromium headquarters. In the Chromium Blog, Chris Evans of Chrome Security announced a cash for bugs initiative, paying between 500 and 1337 USD depending on the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2010/02/Google_Chrome_Browser_log_nobugs.png"><img class="alignleft size-full wp-image-816" title="Google Chrome Browser logo - no Bugs" src="http://www.klocwork.com/blog/wp-content/uploads/2010/02/Google_Chrome_Browser_log_nobugs.png" alt="Google Chrome no bugs" width="142" height="133" /></a>As Google Chrome climbs out of obscurity in the <a title="January 2010 Browser Market Share [according to netmarketshare]" href="http://www.netmarketshare.com/report.aspx?qprid=0&amp;qptimeframe=M&amp;qpsp=132&amp;qpcustomb=" target="_blank">browser market </a>and expands into a light-weight but<a title="Chromium OS" href="http://dev.chromium.org/chromium-os"> fully functional OS</a>, security seems to have become a top of mind issue over at chromium headquarters.</p>
<p>In the Chromium Blog, Chris Evans of Chrome Security announced a <a href="http://blog.chromium.org/2010/01/encouraging-more-chromium-security.html">cash for bugs initiative</a>, paying between 500 and <a title="10100111001 (Leet)" href="http://en.wikipedia.org/wiki/Leet">1337</a> USD depending on the severity for any previously undiscovered flaw.  I am glad to see Google encouraging the community at large to participate in hardening my current browser of choice.  As Chris points out, Mozilla was one of the first to embark on this type of program, but I am happy to see Chrome following suit.  Me and my online transactions appreciate it.</p>
<p>Hmm.  Maybe I should roll-up the sleeves and  invoke the  &#8221;<a title="“I’m gonna write me a new minivan” – is zero software bugs the right goal?" href="http://www.klocwork.com/blog/2009/10/im-gonna-write-me-a-new-minivan-is-zero-software-bugs-the-right-goal/" target="_self">I&#8217;m gonna write me a minivan</a>&#8221; approach and get the driveway cleared for the armored cash trucks.</p>
<p>But seriously, if you&#8217;re interested in helping out and getting a small reward for your efforts, visit the <a title="Chromium Vulnerability Contribution Program" href="http://dev.chromium.org/Home/chromium-security/Chromium_Vulnerability_Contribution_Program_.pdf?attredirects=0&amp;d=1" target="_blank">Chromium Security</a> project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2010/02/google-offers-cash-reward-for-finding-bugs-in-chrome/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Going Agile Part 4 &#8211; Iteration 1: The Good, The Bad, and the Ugly</title>
		<link>http://www.klocwork.com/blog/2010/01/going-agile-part-4-iteration-1-the-good-the-bad-and-the-ugly/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=going-agile-part-4-iteration-1-the-good-the-bad-and-the-ugly</link>
		<comments>http://www.klocwork.com/blog/2010/01/going-agile-part-4-iteration-1-the-good-the-bad-and-the-ugly/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 16:09:57 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[scrum]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=689</guid>
		<description><![CDATA[I just couldn’t resist using the classic spaghetti Western as the title for this instalment of my Going Agile series because it a) it was an awesome movie, and b) it truly sums up that 1st iteration of ours. My last post was all about the 1st iteration planning meeting, and how it was such [...]]]></description>
			<content:encoded><![CDATA[<p>I just couldn’t resist using the classic spaghetti <a href="http://en.wikipedia.org/wiki/The_Good,_the_Bad_and_the_Ugly">Western </a>as the title for this instalment of my Going Agile series because it a) it was an awesome movie, and b) it truly sums up that 1<sup>st</sup> iteration of ours. My <a href="http://www.klocwork.com/blog/?p=672">last post </a>was all about the 1<sup>st</sup> iteration planning meeting, and how it was such an exciting and productive time for our team. We came out of that meeting a little weary, but extremely motivated to get to work. We were also just a tad naive.</p>
<p><a href="http://www.klocwork.com/blog/wp-content/uploads/2010/01/the-good-the-bad-and-the-ugly.jpg"><img class="alignleft size-medium wp-image-690" title="the-good-the-bad-and-the-ugly" src="http://www.klocwork.com/blog/wp-content/uploads/2010/01/the-good-the-bad-and-the-ugly-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The next 2 weeks were a roller coaster as we cut our teeth with Scrum. First the good:</p>
<ul>
<li>Communication: the interaction amongst the team members was definitely improved. If someone needed an answer to something, they immediately sought out help. The team realized that if they didn’t get timely answers, tasks wouldn’t get done. They really didn’t want to say those dreaded 2 words, “nothing finished”, in the daily scrum meeting.</li>
<li>Meetings: The <a href="http://www.mountaingoatsoftware.com/scrum/daily-scrum">daily Scrum </a>meetings were kept short and  sweet as everyone said what tasks they had finished, what they were working on, and if there were any roadblocks in the way. If something required further discussion, a break out meeting with the appropriate people was held.</li>
<li>Energy: This was a high performing team to begin with, but there was now a newfound energy and buzz. This was a fun team to be around!</li>
</ul>
<p>As the title suggests, there certainly was some bad in that first iteration.</p>
<ul>
<li>Testing and documentation: These were the 2 areas that struggled the most in the first iteration (and the next couple as well). They felt that their work was too heavily back loaded, that is, they would receive their stuff too late in the iteration to either test or document properly. Many of the stories were not totally Done because they were either not tested properly or documented with the time they were given.</li>
<li>Defects and bugs: Because testing happened so late in the iteration, many of the bugs they found could not be addressed in that iteration. These bugs would have to be carried over to the next iteration, meaning the number of new stories would have to be reduced.</li>
</ul>
<p>Now for the ugly.</p>
<ul>
<li>After just a day or so into the iteration, a plethora of unplanned tasks starting showing up on the Scrum board for many of the stories. These stories now had many new hours of tasks added to them, and we fell behind very quickly. This leads into the next ugly&#8230;</li>
<li>The <a href="http://en.wikipedia.org/wiki/Burn_down_chart">Burndown</a> chart: Talk about a misnomer! We started to affectionately call our chart the burn-up chart, because there was very little down direction going on with it. Our chart would have looked great at a sales meeting, but in our Scrum meeting, not so much.</li>
</ul>
<p>So as you can see our 1<sup>st</sup> iteration had its share of warts, and in fact, the next couple did as well. But we didn’t get frustrated. We learned from our mistakes and changed/added things based on those mistakes. The <a href="http://www.infoq.com/news/2009/09/key-elements-agile-retrospective">Retrospective</a> meetings were incredibly useful because they made us all take a hard, honest look at what went well, and what didn’t. The next, and last entry in my Going Agile series will look at the Retrospective meeting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2010/01/going-agile-part-4-iteration-1-the-good-the-bad-and-the-ugly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Static Analysis to 0day Exploit &#8211; a demonstration</title>
		<link>http://www.klocwork.com/blog/2009/12/from-static-analysis-to-0day-exploit-a-demonstration/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=from-static-analysis-to-0day-exploit-a-demonstration</link>
		<comments>http://www.klocwork.com/blog/2009/12/from-static-analysis-to-0day-exploit-a-demonstration/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 22:32:40 +0000</pubDate>
		<dc:creator>Eric Hollebone</dc:creator>
				<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[0day exploit]]></category>
		<category><![CDATA[buffer overrun]]></category>
		<category><![CDATA[software security]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=528</guid>
		<description><![CDATA[I have always been fascinated by the whole area of code vulnerabilities and security exploits and how hackers turn those issues into real-world problems for the rest of us. Jeremy Brown posted an interesting article on Jeremy&#8217;s Computer Security blog where he uses his security know-how to draw a straight line between a software vulnerability found with [...]]]></description>
			<content:encoded><![CDATA[<p>I have always been fascinated by the whole area of code vulnerabilities and security exploits and how hackers turn those issues into real-world problems for the rest of us.</p>
<p>Jeremy Brown posted an interesting article on <a title="From Static Analysis to 0day Exploit" href="http://jbrownsec.blogspot.com/2009/12/from-static-analysis-to-0day-exploit.html" target="_blank">Jeremy&#8217;s Computer Security blog</a> where he uses his security know-how to draw a straight line between a software vulnerability found with <a href="http://www.klocwork.com/products/insight/klocwork-truepath/">static analysis</a> and a real <a href="http://en.wikipedia.org/wiki/0day">0day</a> exploit on an open source project called <a title="The Graphical Audio Language" href="http://galan.sourceforge.net/" target="_blank">gAlan</a>.</p>
<p>Jeremy takes us on a short journey where he finds an unprotected buffer with static analysis, creates an exploit payload to cause a buffer overrun, rewrites the instruction pointer and executes a telnet session, demonstrating how easy it is to turn a run of the mill application into a tunnel into the OS.</p>
<p>One of my colleagues did a similar <a title="Firefox vulnerability" href="http://www.klocwork.com/resources/on-demand-webinar/exploit-software-defect-firefox" target="_blank">presentation</a> like this a few years back with a Firefox vulnerability but this is a much better example! Very cool work Jeremy.</p>
<p>Enjoy&#8230;<br />
<object id="viddler" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="437" height="370" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="fake=1" /><param name="src" value="http://www.viddler.com/player/2af2aaf3/" /><param name="name" value="viddler" /><param name="allowfullscreen" value="true" /><embed id="viddler" type="application/x-shockwave-flash" width="437" height="370" src="http://www.viddler.com/player/2af2aaf3/" name="viddler" flashvars="fake=1" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/12/from-static-analysis-to-0day-exploit-a-demonstration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;I&#8217;m gonna write me a new minivan&#8221; &#8211; is zero software bugs the right goal?</title>
		<link>http://www.klocwork.com/blog/2009/10/im-gonna-write-me-a-new-minivan-is-zero-software-bugs-the-right-goal/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=im-gonna-write-me-a-new-minivan-is-zero-software-bugs-the-right-goal</link>
		<comments>http://www.klocwork.com/blog/2009/10/im-gonna-write-me-a-new-minivan-is-zero-software-bugs-the-right-goal/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 19:16:55 +0000</pubDate>
		<dc:creator>Eric Hollebone</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[General Industry]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[bugs]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=473</guid>
		<description><![CDATA[I have always loved &#8220;I&#8217;m gonna write me a new minivan&#8221;  from Scott Adams.  To me, it never gets old.  Originally published in 1998, the theme that applied then still does today: driving 100% of defects or bugs out of the code-base is a laudable goal, but is it really the right one?   I would have to argue [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left; "><img class="alignnone size-full wp-image-478" title="dilbert-minivan-small" src="http://www.klocwork.com/blog/wp-content/uploads/2009/10/dilbert-minivan-small.png" alt="dilbert-minivan-small" width="450" height="147" /></p>
<p style="text-align: left; ">I have always loved &#8220;I&#8217;m gonna write me a new minivan&#8221;  from <a title="Dilbert.com" href="http://www.dilbert.com" target="_blank">Scott Adams</a>.  To me, it never gets old.  Originally published in 1998, the theme that applied then still does today: driving 100% of defects or bugs out of the code-base is a laudable goal, but is it really the right one?   I would have to argue no.  There&#8217;s no silver bullet out there that will find all software defects and solve issues automagically, and until there is, software development will continue to struggle with prioritization.  Unfortunately, we live in a world of finite resources and constantly evolving demands, but we can always dream about being Wally for a little while.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/10/im-gonna-write-me-a-new-minivan-is-zero-software-bugs-the-right-goal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 5 Java quality bugs</title>
		<link>http://www.klocwork.com/blog/2009/10/top-5-java-quality-bugs/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=top-5-java-quality-bugs</link>
		<comments>http://www.klocwork.com/blog/2009/10/top-5-java-quality-bugs/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 14:58:33 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[embedded development]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=451</guid>
		<description><![CDATA[In a previous posts I reviewed the Top 5 C/C++ and Top 5 C# quality bugs that I that I see time and time again looking at customer code. I wrote my Java Top 5 with an embedded programming focus and the folks at www.embedded.com decided to publish it on their site. Here’s a snippet [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous posts I reviewed the <a href="http://www.klocwork.com/blog/2009/07/top-5-cc-quality-bugs/" target="_blank">Top 5 C/C++</a> and <a href="http://www.klocwork.com/blog/2009/09/top-5-c-quality-bugs/" target="_blank">Top 5 C#</a> quality bugs that I that I see time and time again looking at customer code. I wrote my Java Top 5 with an embedded programming focus and the folks at <a href="http://www.embedded.com" target="_blank">www.embedded.com</a> decided to publish it on their site. Here’s a snippet below and the full Top 5 Java bugs article can be found <a title="Top 5 Java bugs" href="http://www.embedded.com/columns/guest/220300859" target="_blank">here</a>.</p>
<p style="padding-left: 30px;">While C dominates as the programming language of choice for embedded development, the use of Java is definitely on the rise. In fact, according to a recent VDC survey, 12.3% of respondents currently use Java in the embedded space, and 17.9% expect to be using Java in the next two years.</p>
<p style="padding-left: 30px;">For those transitioning from embedded development using C, you might find yourself falling into the hype that Java is a &#8220;safe&#8221; language. For example, Java developers face no requirement for managing memory associated with objects. However, this is where the trap may be laid. Even though there&#8217;s no need for memory management, developers may need to keep track of specific resources the object allocates. This is especially true in an embedded context where resources are often constrained. Even for experienced developers, these traps pop up time and again and can easily jeopardize your code quality and security.</p>
<p style="padding-left: 30px;">Here&#8217;s a round-up of the top five programming issues developers should be aware of in embedded Java development [<a href="http://www.embedded.com/columns/guest/220300859" target="_blank">More...</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/10/top-5-java-quality-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 5 C# quality bugs</title>
		<link>http://www.klocwork.com/blog/2009/09/top-5-c-quality-bugs/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=top-5-c-quality-bugs</link>
		<comments>http://www.klocwork.com/blog/2009/09/top-5-c-quality-bugs/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 15:45:03 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[quality bugs]]></category>
		<category><![CDATA[source code analysis]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=367</guid>
		<description><![CDATA[In a previous post I provided the top 5 C/C++ quality bugs that I that I see time and time again looking at customer code.  Time for the C# version: 1.    Null pointer exceptions from a method 1                  public class A { 2                      public A foo() { 3                          if (flag) 4                              return null; 5                          return [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous <a href="http://www.klocwork.com/blog/?p=221" target="_blank">post</a> I provided the top 5 C/C++ quality bugs that I that I see time and time again looking at customer code.  Time for the C# version:</p>
<p><strong>1.    Null pointer exceptions from a method</strong></p>
<pre><code>1                  public class A {
2                      public A foo() {
3                          if (flag)
4                              return null;
5                          return new A();
6                      }
7
8                      public void var() {
9                          A a = foo();
10                         if (flag)
11                             a.foo();
12                     }
13
14                     private int flag;
15                 }</code></pre>
<p>This is the most common issue I see.  In this example a warning is issued at line 11 for a possible null pointer exception.  Essentially there is a potential for a null value from the method foo().  I believe I see these issues more than any others  because of the inter-procedural context of this issue.  This example is quite simple, but where you can easily get lost is when that null value is coming from a long method call chain in multiple classes.</p>
<p><strong>2.    Resource leaks</strong></p>
<pre><code>1  using System;
2  using System.IO;
3
4  namespace LeakExample
5  {
6      class Test
7      {
8          public String Run(String name)
9          {
10             StreamReader reader = new StreamReader(name);
11             String result = reader.ReadToEnd();
12             reader.Close();
13             return result;
14         }
15     }
16 }</code></pre>
<p>I think for most of us this is pretty easy to see.   An object of &#8216;StreamReader&#8217; type is allocated and its reference is assigned to the &#8216;reader&#8217; member. If the call to &#8216;ReadToEnd&#8217; throws an exception, control is transferred out of method &#8216;Run&#8217;, variable &#8216;reader&#8217; goes out of scope, the object referenced by it becomes lost, but related resources are not disposed.  See my previous blog <a href="http://www.klocwork.com/blog/?p=36" target="_blank">post</a> on how some people miss this and what you need to do to fix this.</p>
<p><strong>3.    Forward null pointer exception</strong></p>
<pre><code>1                  public class A {
2                      public void foo() {
3                          A a = new A();
4                          if (a == 0)
5                              if (flag)
6                                  a.foo();
7                      }
8                      private int flag;
9                  }</code></pre>
<p>This is another example of a null pointer exception with a twist.  In this example the class data member ‘a’ is compared with 0 value at line 4, and therefore may still be expected to be null when it is dereferenced at line 6.</p>
<p><strong>4.    Reverse null pointer exception</strong></p>
<pre><code>1                  public class A {
2                      public void foo() {
3                          A a = null;
4                          a.foo();
5                          if (a == null)
6                              a = new A();
7                      }
8                  }</code></pre>
<p>Yes, another null pointer exception (getting a theme here?).  Same idea at #3 but in reverse order.  Here they dereference the data member ‘a’ at line 4 but later check for null at line 5.</p>
<p><strong>5.    Empty catch clause</strong></p>
<pre><code>1  class FileHandler {
2      public void Open(String name) {
3          try {
4              // opening file ...
5          } catch (FileNotFoundException e) {   // defect - no statements in the 'catch' clause
6          }
7      }
8  }</code></pre>
<p>Okay, so not exactly the big impact as the top 4, but I just had to mention it.  I’m always guaranteed to see some of these.  Granted they are maintainability issues more than anything else, but c’mon they are there for a purpose.<br />
As promised, I did say that I would post the Java version soon.  It is next&#8230;</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=4d556a68-3448-8a97-810d-d0cc5d75f16f" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/09/top-5-c-quality-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>That’s nice dear, how does it work?</title>
		<link>http://www.klocwork.com/blog/2009/08/that%e2%80%99s-nice-dear-how-does-it-work/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=that%25e2%2580%2599s-nice-dear-how-does-it-work</link>
		<comments>http://www.klocwork.com/blog/2009/08/that%e2%80%99s-nice-dear-how-does-it-work/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 14:52:58 +0000</pubDate>
		<dc:creator>Gwyn Fisher</dc:creator>
				<category><![CDATA[General Coding]]></category>
		<category><![CDATA[General Industry]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[Software Security]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[source code analysis]]></category>
		<category><![CDATA[Truepath]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=286</guid>
		<description><![CDATA[Ever been faced with that glassy-eyed expression, the look of unthinking, unwholesome fear when some long, incomprehensible word escapes your geeky mouth and upsets the maiden aunts around the once-a-year, wear-your-best-tie, try-not-to-die-before-the-cake’s-all-gone tea table? OK, so this paper won’t help you in that situation whatsoever, but if you replace your maiden aunts with a bunch [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_290" class="wp-caption alignleft" style="width: 130px"><a href="http://www.klocwork.com/resources/white-paper/truepath-scalable-whole-program-static-analysis"><img class="size-thumbnail wp-image-290" title="Klocwork Truepath whitepaper" src="http://www.klocwork.com/blog/wp-content/uploads/2009/08/klo_truepath_print-150x150.png" alt="TruPath whitepaper" width="120" height="120" /></a><p class="wp-caption-text">Truepath Analysis</p></div>
<p>Ever been faced with that glassy-eyed expression, the look of unthinking, unwholesome fear when some long, incomprehensible word escapes your geeky mouth and upsets the maiden aunts around the once-a-year, wear-your-best-tie, try-not-to-die-before-the-cake’s-all-gone tea table? OK, so this paper won’t help you in that situation whatsoever, but if you replace your maiden aunts with a bunch of your best geek friends, and replace the tea with a sturdy helping of Dew, knowing how a real whole program analysis solution works might just conceivably come in handy. Some day. “Dude, I was totally stoked when I read this thing, trust me it’s <em>ahh-some.</em>” Maybe.</p>
<p>Anyway, in the best traditions of self-serving corporate PR blogs everywhere, I give you… drum roll please… <a title="Whole Program Source Code Analysis" href="http://www.klocwork.com/resources/white-paper/truepath-scalable-whole-program-static-analysis" target="_blank">Whole Program Analysis, the Klocwork Way</a>.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/08/that%e2%80%99s-nice-dear-how-does-it-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 5 C/C++ quality bugs</title>
		<link>http://www.klocwork.com/blog/2009/07/top-5-cc-quality-bugs/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=top-5-cc-quality-bugs</link>
		<comments>http://www.klocwork.com/blog/2009/07/top-5-cc-quality-bugs/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 15:06:40 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[Software Quality]]></category>
		<category><![CDATA[array index out of bounds]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[memory leaks]]></category>
		<category><![CDATA[null pointer dereference]]></category>
		<category><![CDATA[uninitialized variables]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=221</guid>
		<description><![CDATA[A recent article on the top five causes of poor software quality and top 5 non-technical mistakes inspired me to also provide a top five on software quality bugs.  Here is my top 5 list of bugs (with some simple examples) that I see time and time again looking at customer code: 1.    Null Pointer [...]]]></description>
			<content:encoded><![CDATA[<p>A recent <a href="http://itmanagement.earthweb.com/entdev/article.php/3827841/Top-Five-Causes-of-Poor-Software-Quality.htm" target="_blank">article</a> on the top five causes of poor software quality and top 5 non-technical <a href="http://www.makinggoodsoftware.com/2009/07/07/5-top-non-technical-mistakes-made-by-programmers/" target="_blank">mistakes</a> inspired me to also provide a top five on software quality bugs.  Here is my top 5 list of bugs (with some simple examples) that I see time and time again looking at customer code:</p>
<p>1.    Null Pointer dereference</p>
<p>This is far and beyond the most common issue that I see time and time again. </p>
<pre><code><span style="font-family: Courier New;">void npd_gen_must() {
int *p = 0; // NULL is assigned.
*p = 1;  // pointer is dereferenced
}</code></pre>
<p>Now this example is pretty basic and if you ever did something this obvious, maybe it was time to re-evaluate your development skills.  The idea is simple, you assign NULL somewhere then dereference it at some point later.  This is usually missed under a complicated control flow (many conditionals).  Or even more common is the fact that I see memory is allocated, but is never checked against NULL.  Now, some organizations don’t care about this but I would hope anyone doing embedded development is all over it.</p>
<p>2.    Null pointer dereference from function</p>
<p>This is really the same thing but with one very important difference.  This deals with issues from functions. </p>
<pre><code><span style="font-family: Courier New;">void xstrcpy(char *dst, char *src) {
if (!src) return;
 dst[0] = src[0];
}

char global;

char *xmalloc() {
  if (global) return &amp;amp;global;
  return 0;
}

void npd_func_might(int flag, char *arg) {
  char *p = &amp;amp;arg;
  if (flag) p = xmalloc(); // xmalloc() may return NULL
  if (arg) { p = arg; } // p may get a new value here
  xstrcpy(p, "Hello"); // p will be dereferenced in xstrcpy()
}</code></pre>
<p>It is this inter-procedural (spanning multiple files/functions) context that is often overlooked.</p>
<p>3.    Memory leaks</p>
<p>I have yet to find a programmer in the C/C++ world who doesn’t know this intimately.  Sadly they happen, a lot. </p>
<pre><code><span style="font-family: Courier New;">void foobar(int i) {
  char* p = new char[10];
  if(i) {
    p = 0;
  }
  delete[] p;
}</code></pre>
<p>Here we have dynamic memory stored in &#8216;p&#8217; and allocated through the function &#8216;new[]&#8216; at line 3 and is ultimately lost at line 5.</p>
<p>4.    Array index out of bounds</p>
<p>Again, most people know what these are but there are so many variations of this that they are always inevitable. </p>
<pre><code><span style="font-family: Courier New;">int main() {
  char fixed_buf[10];
  sprintf(fixed_buf,"Very long format string\n");
  return 0;
}</code></pre>
<p>The string is 24 characters so at line 4 the array index of &#8216;fixed_buf&#8217; may be out of bounds. </p>
<p>5.    Uninitialized variables</p>
<pre><code><span style="font-family: Courier New;">int foo(int t) {
  int x;
  if (t &amp;gt; 16) {
    x = 1;
  } else if (t &amp;gt; 8) {
    x = 2;
  }
  return x + 1;
}</code></pre>
<p>The value of variable &#8216;x&#8217; can be used at line 8, when it might be uninitialized.  I always found these surprising that these come up as they are pretty basic.  But I tend to only see these in complex control flow paths.  So the developer might check for these under normal conditions but forgot on some path.  Especially for legacy code this might not bite you until you change something later on.</p>
<p>So that’s it.  These examples are pretty simple and certainly not reflective of the real world (or at least I hope not).  Later I will post the same idea for Java code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/07/top-5-cc-quality-bugs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bugs and your Backlog</title>
		<link>http://www.klocwork.com/blog/2009/07/bugs-and-your-backlog/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=bugs-and-your-backlog</link>
		<comments>http://www.klocwork.com/blog/2009/07/bugs-and-your-backlog/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 17:28:44 +0000</pubDate>
		<dc:creator>Todd Landry</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[backlog]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[iteration]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=219</guid>
		<description><![CDATA[There was a recent blog on whether or not you should have bugs (that were not found during the most recent iteration) added to your product backlog, or kept in a separate bug backlog. Here at Klocwork we have a defect database that is closely monitored by Support, dev, PM, and so on&#8230;suffice it to [...]]]></description>
			<content:encoded><![CDATA[<p>There was a recent <a target="_blank" href="http://blog.mountaingoatsoftware.com/bugs-on-the-product-backlog">blog </a>on whether or not you should have bugs (that were not found during the most recent iteration) added to your product backlog, or kept in a separate bug backlog. Here at Klocwork we have a defect database that is closely monitored by Support, dev, PM, and so on&#8230;suffice it to say, it has a high degree of visibility within the organization and will probably never go away. Being an Agile company we also have a product backlog that is reviewed daily and prioritized regularly. Every two weeks (coinciding with our iteration planning) PM and Support get together to discuss the highest priority bugs, and to determine if those bugs should/need to be added to the backlog for the next iteration. A key piece to this process is using tools to maintain this backlog. The backlog tool, which also has an integration with our defect tracking system provides a tight correlation between the two, and a level of automation that makes life a little easier for everyone. Once added, these bugs are prioritized just as we do with all of the other features (stories) we have in the backlog. We also have weekly status meetings where the most recent bugs are discussed, once again to ensure they receive the proper attention. </p>
<p>Since we are in the bug-finding business, we take bugs very seriously and adding them to our backlog (and as a part of our iteration planning) helps ensure we address them quickly. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/07/bugs-and-your-backlog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resource Leaks in C#</title>
		<link>http://www.klocwork.com/blog/2009/02/resource-leaks-in-c/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=resource-leaks-in-c</link>
		<comments>http://www.klocwork.com/blog/2009/02/resource-leaks-in-c/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 15:13:57 +0000</pubDate>
		<dc:creator>Alen Zukich</dc:creator>
				<category><![CDATA[Nasty Bugs]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[resource leaks]]></category>
		<category><![CDATA[Static Analysis]]></category>

		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=36</guid>
		<description><![CDATA[I’m picking up the theme of the CWE Top 25 today (see posts below for more detail on the list itself, or check out this blog posting for a more exhaustive description) as we run into what is described as CWE-404 all the time in managed code environments. Although most C/C++ developers recognize explicit resource [...]]]></description>
			<content:encoded><![CDATA[<p>I’m picking up the theme of the CWE Top 25 today (see posts below for more detail on the list itself, or check out this <a href="http://sharpertutorials.com/top-25-dangerous-coding-errors/" target="_blank">blog</a><a href="http://sharpertutorials.com/top-25-dangerous-coding-errors/" target="_blank"> posting</a> for a more exhaustive description) as we run into what is described as <a href="http://cwe.mitre.org/data/definitions/404.html" target="_blank">CWE-404</a> all the time in managed code environments.</p>
<p>Although most C/C++ developers recognize explicit resource management as an issue, I’ve recently found out talking to some of our customers that they are totally unaware of the need to worry about such things in Java and especially C#. I even had one customer tell me in the context of C# that the CLR will “take care” of the issue. While it’s perhaps true that eventually the Finalize() method might take care of many resources, professional developers really should take the utmost care in dealing with precious unmanaged resources like file handles, graphics handles, or database connections.</p>
<p>A simple but surprisingly common example in C# illustrates the point:<br />
<em><br />
using System;<br />
using System.IO;</em></p>
<p><em> </em></p>
<p><em>class Blah<br />
{<br />
static void Main()<br />
{<br />
StreamReader r = null;<br />
r = File.OpenText (“blah.txt”);<br />
if (r.EndOfStream) return;<br />
Console.WriteLine (r.ReadToEnd());<br />
}<br />
}</em></p>
<p>The StreamReader class used here encapsulates an unmanaged resource, the underlying file handle that the O/S allocates to the CLR during the call to OpenText(). As you can see, that unmanaged resource is never released back to the O/S (until such time as the application terminates, of course).</p>
<p>A simple statement:</p>
<p><em>r.Close();</em></p>
<p>in a finally block would clean it up.  Calling Close directly is okay but it is crucial to make sure you put that in the finally block.  The most common resource leaks that I see static analysis tools find are the ones where you see a developer has been smart enough to dispose of his resource but there is another path (such as an exception that can be thrown on a method) where the resource is not disposed.</p>
<p>Another easier way to dispose of the resource is to apply the “using” statement, which calls Dispose on an IDisposable object automatically for you. This code:</p>
<p><em>using (Streamreader r = File.OpenText (“blah.txt”))<br />
{<br />
…<br />
}</em></p>
<p>is the same as writing:</p>
<p><em>Streamreader r = File.OpenText (“blah.txt”);<br />
try<br />
{<br />
…<br />
}</em></p>
<p><em> finally<br />
{<br />
if (r != null)<br />
((IDisposable)r).Dispose();</em></p>
<p><em> }</em></p>
<p>So make sure you know that you need to dispose of certain resources.  In fairness, these can be hard issues to detect, particularly in an inter-procedural context, but good regimented use of code reviews, coupled with a good static analyzer should get you well on your way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klocwork.com/blog/2009/02/resource-leaks-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
