I have a multi-threaded VisualStudio2003 C++ based application, which I
am running on Win2000/WinXP. During stress testing on multi-processor
workstations, I am seeing a stange error in which:
1. a file creation call to fopen("xxx", "wt") returns a valid file
pointer, and writes to the file are performed OK.
2. but then a another call to fopen("yyy", "wt") from another thread
trying to create a different filename returns the SAME file pointer as
the first fopen call. (although I did not fclose() the original...
3. From that moment on, all writing to the identical file pointers wil
result in writing to the second file.

- I am using AfxBeginThread() to create the threads.

- This only occured on multiprocessor machines, and not on single
processor machines.

- I am using the libcmt (thread safe runtime library)

- So far, replacement of the runtime library calls like fopen() /
fwrite()... with Win32 calls such as CreateFile() and WriteFile() seem
to have fixed this, but I do not understand how this could happen in
the first place.

It smells like a thread safety issue with the "thread safe" runtime
library version, but I have not found any internet links describing
similar things.

Any ideas?!?