Surfulater V1.82, B0.0 released

It has been a troublesome few weeks with two people (Gad Chang and Bernard Jennings) reporting that Surfulater was crashing when they started it. First thoughts pointed to the possibility that another application had been installed and that had caused Surfulater to come to grief (usually referred to as DLL Hell), but this wasn’t the case. Problems like this can be very difficult to track down, because they usually can’t be reproduced by anyone except the person having the problem. There was nothing in Surfulater’s log file which gave me any clues either. Fortunately I had the thought that it may be something in the Knowledge Base files that was triggering the crash, so I asked for copies of the files to be sent to me and sure enough I was able to see the exact same crash.

The next task was to try and pin-point the cause of the crash, which turned out be be quite easy. I had written some code to handle a very specific error condition which occurred when the size of a KB (XML) file was a multiple of 4096 bytes, but for some reason this code wasn’t working and Surfulater was crashing. Digging a bit deeper it turned out that the error handling code was missing completely, which made absolutely no sense.

Time to hit Google and some other programming sites I frequent. Before long I received a reply that identified the precise reason for the disappearing code. I program in C++, or more precisely Microsoft C++ and it like all professional compilers includes a Code Optimizer. Code optimizers analyze the code we mere mortals write and do things like attempt to make it run faster, or produce smaller programs. The Surfulater problem turned out to be a documented bug in the MS C++ Compiler where it optimized my error handling code out of existence!

Optimization bugs like this used to be fairly common place 15 years ago, but you rarely see them these days. So I was very surprised to see this, especially seeing that I’ve written over 180,000 lines of C++ code in past 7 or so years and never encountered this before.

The fix that MS recommended didn’t work at first either and it took quite a few hours of head scratching to get the code to behave as it should.

As part of this exercise I decided it was an opportune time to include thorough Crash Handling and Reporting code, which had been on the todo list for quite some time. I was able to add some great code by Hans Dietrich and after a few tweaks here and there I’m very pleased with the results. This means that if Surfulater crashes big time like in the problem above, we can get detailed crash information e-mailed to us which will help us locate the problem and fix it far more efficiently.

I’ve included some screen shots below of the new Crash Handler dialogs, which hopefully you will never get to see in real life.

Crash Reporting Dialog

Crash Report Details

These are similar to and perform much the same task as the Crash reporting code in Windows, which enables you to report a crash back to Microsoft. But instead of reporting it to Microsoft it reports it to us, which is far more useful all round.