Wednesday 27 February 2008

How Microsoft caused apache & php_mysql.dll to fail...using VISTA (dwmApi.dll)

The Background

Last week I discovered I had quite a few viruses etc.. on my laptop. So I needed to reformat the hard-drive and re-install WindowsXP before I started my new job.

Now before I did all this, I made sure I had a complete back-up of everything off the machine. NB: this is my main development machine... it is a very nice HP laptop.

Before I did this, I had a very nice fully working development environment, i.e.: Cygwin, IDEs, Java VM (1.4/1.5/1.6), mySQL, all my tools, compilers, disassemblers, apache 2, php 5, remote access etc...

So WHY.... did PHP5 refuse to work when I re-installed it today....?!!!

Well, sit back and I will tell you a story of detective work and a serious mistake that seems to have got through to cause me and others, a huge problem.

The Story

I needed to re-install a php environment today, so I could test the environment I am recommending to my current client.

So I copied everything back on my machine, ran a quick command line PHP test (which worked) and tried to start apache.... and it FAILED... with:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\_dev\\php5\\ext\\php_mysql.dll'

Considering it had worked on the command line, I thought this was a little strange. But config issues are normal, so... it needed a little work. I am quite used to this, having done it far too many time over too many years.

Over the next FOUR hours... I re-installed apache twice, PHP twice, rebooted a few times and re-ran the configuration at least four times.

I still had php alone working fine, but php through apache failing... with a message that simply made no sense.

So now I started to get frustrated and went hunting on google..

The Chase

After a while, I found a few forum threads that talked about using Dependency Walker to see what php_mysql.dll actually needed, and why it should be failing.. So I downloaded the software and checked it out.

Dependency Walker immediately reported a failure in the dependencies. DwmAPI.dll.

Ok, that seems a little odd...

So, off I went back to google to see what I could find out.

It turns out that DwmAPI.dll is a Desktop Windows Manager API... and after a load more research I found out... for Windows VISTA...!!!!

Now I was pissed.

The Fury

Some idiot had compiled a dependency to the wrong operating system into one of my tools.

At least I now had a culprit... all I had to do was track down the criminal.

AND GUESS WHAT.... it was Internet Explorer 7.

Look at the tree... DwmAPI.dll is a dependency of IEFRAME.dll, which I recently gained, when I decided to bite the bullet and install IE7.

What a £$%&ing mistake that was...

So now I was even more pissed off.

I had spent hours debugging to find an error that should never have existed from the people who created the operating system I depended on.

At least I should be able to fix it.

The Fix

Well, on that point I can at least put one happy note forward.

IE7 uninstalled in 5 minutes... I rebooted... I started apache... I checked the error log files and..... IT WORKED...!

And just to prove a point...
Here is the Dependency Walker result after I had un-installed IE7.

And the moral of this story.....

IE7, PHP, Apache and the word NOT features quite heavily.

... you work it out. :->

But... this has been enough of a serious headache to make me think about ditching windows for a *nix machine. Either OSx or Linux.

Considering I have been a windows(less than fanatical) user for quite a while, mainly due to client pressure... it is ironic that the systems I use to develop and now being pushed off machines that keep me using their software...

To Microsoft:
You have created a bug that makes the primary web development environment crash. And you have done it with your browser.. something the same web developers really need to install for testing.
Were I a more paranoid type... I would be suggesting this was deliberate.

1 comment:

  1. Incidentally, if you skipped to the end of my previously posted solution, visitors might miss (but it is still important to know), that the VC9 version of Apache and PHP is designed for IIS. Therefore, "i defaye" (above) may simply have had the "choose the right architecture for your OS setup" problem. It's hard to say without more info; it can be a tricky setup, what with all the paths, versions, and config files that [have to be / have to know how to] set up exactly right. Good luck folks.