Wednesday, March 13, 2013

A bug that is so deadly that can kill you...

A short story that I wouldn't want anyone else to live. Yesterday I was creating new animations with the Mystic Framework and found a small bug that I wanted to fix, nothing  important but was related to a UI glitch of the animation editor, so I decided to put some breakpoints and find the culprid class that created that annoying glitch and suddenly Visual Studio showed an error telling me that the source code is not matching the current build, ok I said , I will stop and rebuild so I can continue debugging, soon after it stopped around 2000+ errors popped up on the screen. This doesn't looks good, anyway, I am tired now so the best way is to quit and reload, and probably no errors will show up since I haven't closed VS for the last 3 days, well after loading the application to my surprise surprise! errors were still there, and after trying to figure out what was going on, I noticed that magically nearly 1.5 megabytes of code was gone from many classes, I don't really know how is that possible but many files were affected and the code was gone, nowhere to be found, only being able to see some code that maybe I wrote about a year ago and few pieces of code here and there was there!, I went from very angry to very sad in a second of my life.

Not all is lost, luckily, I made some periodic backups, I used to have a backup utility but it stopped working long ago, but didn't care to find a new one because I wanted to keep coding, so I only did the minimum and keep doing manual backups and zip the files, saddly the most recent back was made about 15 days ago, but not all is lost, keeping a log file in another place with the tasks I made since I started allowed me to find what I did, and restoring the old files plus using some code that I was able to salvage restored maybe 98% of the missing code or even a little bit more, and I only had to spend 2 hours more verifying that the code worked with minimum patching since the code was quite fresh in my mind I could easily fix it.

Now, I am a little bit worried that this may happen again, about 4 to 5 months ago something similar happened but was not serious just a few lines of code was lost, but this time it was almost everything I worked on the in the past 6 months or maybe more, so my weekend task is going to be "find a good backup utility", I haven't been able to find yet an "incremental" backup tool with zip capabilities so I don't get my hd full of backups, I saw a few ones here and there but most of those tools just synchronize files without compression, and without scheduler, I don't need a 5 minute backup tool, just once a day is more than enough so I can backup different folders and compress the new output, if none are available , something I doubt, I may have to write one but I don't want to spend time on it since I prefer to keep doing testing and fixing some other bugs in game as well as adding more gameplay features.

The bug in VS happened on all the form files I was using, I have one main form but its code is divided into several files for readability, so at some point of time VS may have gotten confused and broke in pieces and taking my code with it. Hope this thing doesn't happen to anyone else in the future.