These are difficult bugs I’m being given. Fortunately, I am getting through them. I had hoped to have another beta out by now, but theres a few more fixes to do first.
I had a couple of those unexplainable programming occurrences happen. The worst was after I had done those two very difficult fixes, with the help of Uwe in the comments on my last blog post, and with the help of the LMD people on their newsgroup. I made those fixes and then was getting ready to go forward to the next item, and all of a sudden the files were loading much slower. I mean like 20 times slower.
It took me a while to trace this to where it was happening. First I tried using Eric Grange’s Sampling profiler that I was hoping to use in the future for optimization. I was terribly disappointed in how it couldn’t get me close to where the problem was. It was listing system routines with 90% of the time being string copies. Well I know that is going on at the low levels. What I want to know is from whence that is being called.
So I went back to AQTime. They just put out version 6.30 which finally includes integration into Delphi 2009, so it was worthwhile me trying it again. Of course, they’re still behind the times, because Delphi 2010 has been out for awhile so they’re over a year behind in their Delphi integration.
The AQTime Delphi 2009 integration didn’t help. Seemed to be buggy and I couldn’t get it to profile by line. So I did it externally and right away found the line in question. Problem was, there was absolutely nothing wrong with the line.
I was using Delphi PChars, and adding the length of the block to the starting character pointer to tell it where to stop. But somehow, it did not add correctly, and subtracted 4 instead. So the entire block was being Encoded once for each record, rather than once for each block. And the code was correct. I couldn’t find what was wrong.
I went back to my earlier beta version. It had no problem. I checked my next build. It was okay. Then the next build - that one no longer worked. There was nothing different codewise. I spent a day on it. Possibly some compiling option got changed, or some memory got filled somewhere? I don’t know. But my major changes had happened in the 5 builds since then. After I gave up trying to fix the problem, I had to go back to the working version and add all the changes since then and check step by step that the problem did not reoccur. It did several times along the way. So I had to go back and make fewer changes at a time. Doing so finally got me to my current state without the PChar problem.
So I’m totally perplexed and don’t know what this was. I have to stem my curiosity or I would spend the next two weeks or longer trying to track this down.
But the important thing is to continue on with the beta. So as long as I’ve rid myself of this problem that shouldn’t have occurred anyway, I better just forget about it, pretend it didn’t happen, and just cross my fingers that it doesn’t happen again. I don’t expect that it will, but if it does, then I’ll nail it down and put it away for good.
I guess I had entered the Programmer’s Twilight Zone. Let’s hope I’m out.