I’ve talked before about how working with .NET and Mono on Windows and Linux translated to better code. Now I had that experience with C++ and windows. I’ve been working on a Managed C++ component that interacts with OpenSSL (yuck!). The application performed very well on Vista, Win 2k8, Win 7, etc. But on Win XP sometimes it would die abruptly and unexpectedly. We were presented with a very ugly error at the Event Viewer, the error was so strong that our exception handling mechanisms were completely bypassed.

We thought that it could be some problems with linking and libs on Win XP. It wasn’t our fault, it worked on other machines, it could be that Win XP was just that unstable. But how many times are these problems blamed on so many things except us.

The problem was presented to us more directly when running the application on Win 2k3. While the app just died on Win XP, and nothing was wrong on Vista+, Win2k3 said that the application was wrong, and why.

Apparently we were using some managed strings, and due to some copy paste (the bastard!), we were freeing them not with the correct method (FreeHGlobal) but using FreeBSTR. Result: KABOM! Why we didn’t get any error in Win Vista is beyond me. After fixing that, Win XP version is working like a charm.

Related Posts

Leave a Reply