BUG: AV Using ios-Derived Type in Multithreaded Apps (188721)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++ .NET (2002)
This article was previously published under Q188721 SYMPTOMS
When you create and destroy ios-derived classes in multiple threads, an
access violation can occur.
This only occurs when you use the old iostream library rather than the
Standard C++ Library introduced in Visual C++ 5.0. You can access the old
iostream library by including iostream header files with a .h extension,
such as iostream.h or strstrea.h. The new header files do not have an
extension, such as iostream or strstream.
CAUSE
A static member ios::fLockcInit is used to hold reference counts for a
critical section used in the multi-threaded C Run-Time Library to provide
synchronization for the ios class. Ios::fLockcInit is modified without
synchronization during construction and destruction of ios thereby allowing
a race condition. The critical section reference counted by ios::fLockcInit
may be destroyed more than once or used after it is destroyed.
RESOLUTION
For Visual C++ 5.0, use the Standard C++ Library instead of the old
iostream library.
For earlier versions of Visual C++, either do not use ios-derived classes
or provide synchronization in the CRT and rebuild it. If you rebuild the
CRT, you may not redistribute a DLL named the same as the DLLs Microsoft
ships; you must give the DLL a different name. Microsoft does not support
modified CRTs.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. We are researching this
bug and will post new information here in the Microsoft Knowledge
Base as it becomes available.
MORE INFORMATION
ios-derived classes include: iostream, istream, ostream, fstream, ifstream,
ofstream, strstream, istrstream.
Modification Type: | Major | Last Reviewed: | 12/8/2003 |
---|
Keywords: | kbbug kbpending KB188721 kbAudDeveloper |
---|
|