Microsoft KB Archive/814308

= FIX: Access Violation When You Use ios-Derived Type in Multithreaded Applications =

Article ID: 814308

Article Last Modified on 10/21/2005

-

APPLIES TO


 * Microsoft Visual Studio 6.0 Service Pack 1
 * Microsoft Visual Studio 6.0 Service Pack 4
 * Microsoft Visual Studio 6.0 Service Pack 5

-



SYMPTOMS
When you create and destroy ios-derived classes in multiple threads, you may receive an access violation error message. This problem occurs only when you use the old iostream library instead of the Standard C++ Library that was introduced in Visual C++ 5.0. You can gain access to the old iostream library by including iostream header files that have the .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 that is used in the multithreaded C Run-Time Library. This critical section reference provides synchronization for the ios class. The ios::fLockcInit static member is changed without synchronization when you create and destroy ios. This scenario permits a race condition. The critical section reference count that ios::fLockcInit holds may be destroyed more than one time or may be used after it is destroyed.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

Note You must have a Visual Studio license agreement to obtain this hotfix.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.   Date         Time   Version     Size     File name -  05-Feb-2003  22:57              481,910  Libcimt.lib 05-Feb-2003 22:48              608,636  Libcimtd.lib 05-Feb-2003 23:46  6.0.9746.0   77,878  Msvcirt.dll 05-Feb-2003 22:51  6.0.9746.0   94,285  Msvcirtd.dll 05-Feb-2003 21:11                7,146  _ios.cpp



WORKAROUND
Use the Standard C++ Library instead of the old iostream library.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kbfix KB814308

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.