Some percent of the time, my program is crashing on startup, only in optimized mode.

I know fairly well about static dynamic initialization order fiasco. It behaves exactly like that but my instrumentation seems to say it's being initialized the same as before and ought to be working.

As far as I can tell there's just nothing not being initialized before the crash occurs that could cause some error.

An idea I recently implemented was to use two heaps, the process heap and creating a new heap. I save a handle to the system heap and then create a smaller heap to use for system type allocations which last a long time so that I won't fragment the main heap too much. Can this be the issue? Is there some way to run a heap in the debug mode?

Also, is there some way to have the program spit out info on what is being loaded as it loads it? It seems like a basic and obvious thing to want in cases like this, though I have never had cause to do so until now.

ANy help greatly appreciated.