Re: Endless loop of First Hand Exceptions
chhenning wrote:
For some reason I believe my c++ runtime is messed up. The reason I
say that is that I get an endless loop of the following message when
calling fflush(...):
First-chance exception at 0x8018c470 in WorkerHost.exe: 0xC0000005:
Access violation at location 0x000000008018c470.
So, for the record, you are on a 64-bit system.
The code I using to trigger this problem is simply this:
FILE* f = fopen( "c:\\remove.txt", "w" );
fwrite( "Hello", 1, 5, f );
fflush( f );
Assuming 'f' isn't NULL, the code is fine.
fflush() function never returns. I have tried using ofstream from the
STL but same thing in the end.
Streams come from the IOStreams library, not from the STL. What you mean is
the C++ standard library. ;)
Only when I use Win32 calls like CreateFile(), WriteFile(), etc. I
have no problems.
fopen() and std::fstream are basically wrappers around CreateFile() etc, so
I share your guess that the runtime might cause it.
This only occurs in my debug build and not in my release build. Also,
the problem does not occur with a simple Hello World program.
That again speaks against the runtime but rather for the abuse of the
runtime.
The application I'm trying to debug is a rather big one. Basically a
.net executable is forking of a C++ com module to do some work.
I believe this problem started to occur when I upgraded my VS2005 with
the SP1. Since then I have rebuild all the dependencies of my
application to avoid potential problems with having to deal with
different runtime linked with different modules. But no luck.
Generally I would:
* Revert to a known good state using the version control system (or a
backup) and try again. If that works, jump to a state in the middle and try
if it breaks there etc, until you have the commit that caused the problems.
* Deactivate stuff until it stops breaking, until you find the parts that
breaks things. Might be difficult in your case though.
Specifically I would:
* Check where the debug/release configurations differ.
* Verify that the e.g. the default alignment and packing and the default
calling convention isn't touched in the project settings or some headers.
* Try to create a thread using _beginthread and see if it works in that
thread. This would be a hint that some initialisations are not performed or
not performed correctly.
Good luck!
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Gesch??ftsf??hrer: Thorsten F??cking, Amtsgericht Hamburg HR B62 932