The case of a hard to reproduce bug

 Dec 28th, 2013 

 ,

This is the story of a bug that was hard to reproduce. It is about the investigation and it shows how well intended code can make bugs even harder to reproduce. The bug (and the fix) is trivial. However, a combination of factors make it remarkable.

When Know Inc. starts for the first time after a clean installation, it displays a popup window with an introduction to the game. After the dialog closes it should not show up again. However, on some installations, the dialog would still appears on the second or even third game start. This would happen until a mission was started. Then, it would stop showing up no matter what. The bug was reported about a month ago and until two days ago I was not able to reproduce it.

I uninstalled the game on my phone and reinstalled it from the Store. Then I noticed that every time I start the game, I get the intro popup. On Windows Phone, if you install the game from the Store you cannot access the isolated storage where the files are stored. That can only be done for side-loaded applications. So I had the bug reproducing on my phone but no way to investigate.

I uninstalled the store version of the game and installed the developer version so I can debug. Guess what? I couldn’t reproduce it anymore. At least I knew that it is somehow reproducible on my phone. I tried to remember what I did with the store version before I noticed the bug. I opened the game… clicked the Story button… probably closed the game… opened it again… started a mission… dismissed the how to play dialog… closed the game… I knew it was reproducible, I just had to find the correct steps. Tried for an hour or so but nothing. At that point, I didn’t know that it only works on clean installations (you’ll see soon why). No luck, so that was it, no repro.

I was working on a new feature when I saw the bug again. Eureka! Repro on developer build. The first thing I did was Read the rest of this post »

Testing against today’s date

 May 21st, 2011 

 , ,

Suppose there is an automated test case for a report:

1. Generate a report for today
2. Check if the date printed on the report is today's date

The question is: how can this test case fail?

Read the rest of this post »

Expression evaluation

 May 27th, 2010 

 , , , , ,

Let’s start with a simple quiz: 7/2 = … . Of course is 3.5 but is this also true for code?

If you somehow use a non-fractional data type for storing the result, you will always get the result 3. And that should not surprise you.

int result = 7/2; //expression is 3

However, if you choose to use a fractional data type, things will change …

double result = 7/2;

… or not. The value stored in the variable result is still 3 (actually 3.0 or something really close to 3.0 – since floating point data types store the approximation of a number).

Why is this happening?
Read the rest of this post »

EventInfo.AddEventHandler – bug or not?

 Apr 16th, 2008 

 , , , , ,

Reflection is the process by which a computer program can observe and modify its own structure and behavior. The programming paradigm driven by reflection is called reflective programming. [Wikipedia]

Working a few days ago on a plugin architecture on .NET Framework I’ve found something very interesting. The method System.Reflection.EventInfo.AddEventHandler does late-binding. You’ll probably say “so what?”. Let’s see the problem with an example:

Using Visual Studio 2005/2008, create two C# projects (a windows forms application project and a class library one). Rename the class from the class library project to “TestClass.cs”.

Read the rest of this post »