Well, of course it is really hard without the code, but to my way of thinking, the best starting place is with the differences in your environment.
You already know of one pretty major difference, PHP-CGI vs mod_php, but comparing the two environments' phpinfo() output is where I usually start with such troubleshooting.
Things like register_global, and others, can be relevant - that's where I would check. From your description of the behavior, I would guess it quite likely one of the differences you find may be relevant.
--DreamHost Tech Support