Back in Dec 2005 Charles Cowan reported a problem where Surfulater would crash whenever it went to display one of its pop-up tip Windows. I’d had no other reports of this and was unable to reproduce it on any of our test PC’s. As any software developer will tell you these are the worst type of problems to have.
Over the course of a few days I created several special builds of Surfulater that I sent to Charles in an effort to isolate the precise cause of the problem. The results from this process made little sense at the time and I was unable to get to the bottom of it. Charles informed me that he was having problems with other programs as well and in the end we agreed it was likely a problem with his PC, and not Surfulater. I did suggest a work-around which enabled him to continue using Surfulater, but I was not particularly satisfied with the outcome.
Step forward to earlier this month when Rex Winn told me he was having a problem with Surfulater crashing when capturing new articles. Rex and I went back and forth on this and I concluded fairly quickly that it was the same problem Charles had reported. When a new article is created Surfulater pops up a tip window and there came the same crash. As it fortuitously happened Rex is also a software developer and after lengthy exchange of e-mails he was able to pin-point the cause.Â
Surfulater was working fine on Rex’s PC until he did two things. First he changed his operating system from Windows XP to Windows 2003 Server and second he upgraded the BIOS on his Motherboard. At that point Surfulater would run ok until a pop-up tip was displayed. But then Rex needed to re-boot his PC and after that Surfulater wouldn’t start at all. Like Charles, Rex mentioned he was also having problems with some other programs and the only way to get these programs to work was to turn off Data Execution Protection.
I hadn’t heard of Data Execution Protection or DEP, so it was time to hit Google. The first thing I found was that DEP wasn’t enabled on my PC, so I quickly rectified that, started Surfulater and it worked perfectly. Next I discovered there are two aspects to DEP, Software DEP and Hardware DEP and I’d only enabled Software DEP. Hardware DEP is only available on newer PC’s, so I didn’t even know if my PC supported it. After some digging around in the BIOS I found the option that enabled Hardware DEP, turned it on, started Windows, then Surfulater and low and behold I was able to reproduce the problem Charles and Rex were having with the pop-up window. Everything else worked fine and the problem where Rex couldn’t even start Surfulater remained a real mystery.
So now it was time to start digging and find out precisely what was causing DEP to throw its hands up in horror and kill Surfulater. Before I do let me provide some information on DEP from Microsoft.
Data Execution Prevention (DEP) is a set of hardware and software technologies that perform additional checks on memory to help prevent malicious code from running on a system. In Microsoft Windows XP Service Pack 2 (SP2) and Microsoft Windows XP Tablet PC Edition 2005, DEP is enforced by hardware and by software.
The primary benefit of DEP is to help prevent code execution from data pages. Typically, code is not executed from the default heap and the stack. Hardware-enforced DEP detects code that is running from these locations and raises an exception when execution occurs. Software-enforced DEP can help prevent malicious code from taking advantage of exception-handling mechanisms in Windows.
The bottom line here is that DEP will help prevent Trojan and Virus programs from running on your PC, which is an admirable goal.
So back to Surfulater. It turned out that some third party code I use was causing the problem by trying to assemble and execute code in a data section. This has been something Windows programmers have been doing forever, but can no longer, at least on Windows XP SP2 and Windows 2003 SP1 with DEP enabled. The good news was that other folks using this same code were aware of the problem and several solutions had been presented. Kevin Hoffman’s code was a perfect fit and after a few hours reworking my code, Surfulater and DEP played happily together. I quickly sent a copy off to Rex to try who ecstatically reported his favourite program was working perfectly again.
To quote Rex:
The good news is that it *WORKED* YOU ROCK!!!
The bad news… THERE ISN’T ANY!!! SWEET!!! I’m back into SUL and
loving it!!! WOOOOHOOOO!!!
As I said at the start these are the worst sorts or problems to track down. Rex’s help was truly invaluable and for that I remain indebted.
A final word of advice for any programmer’s reading this. Ensure you thoroughly test you code with both Hardware and Software DEP enabled.
And to my Surfulater readers Version 1.97, Build 0.20 was released today with this updated code in place. Download here.