Article ID: 193100 - View products that this article applies to.
This article was previously published under Q193100
This article has been archived. It is offered "as is" and will no longer be updated.
When serializing in a Unicode CString in an MBCS MFC application or vice versa, the CString from file is read in, converted to a CString of the build type, and the original CString is deleted. When deleting the original CString you may see an access violation or invalid page fault. The problem code is on line 270 in Arccore.cpp. The symptoms described here are evident only in release builds.
CString in the release build uses its own memory manager (the CFixedAlloc class) for strings of size less the 512 bytes. So for all CString (of less than 512 bytes) allocations made by CFixedAlloc::Alloc() through CString::AllocBuffer() and the corresponding deallocations are made by CFixedAlloc::Free through CString::FreeData(). In the CString serialization function operator:
>> (CArchive& ar, CString& string)
instead of calling CString::FreeData() to free the data, the operator delete is called and this can cause the above mentioned problem.
Change line 270 in Arccore.cpp from the following:
to the following:
Rebuild the MFC libraries and statically link to it. The following command builds the debug MFC library without CodeView information (Nafxcwd.lib):
NMAKE DEBUG=1 CODEVIEW=0Further information on building a static link library variant can be obtained from the Readme.txt file that ships with Visual C++, or in xxxx\MFC\SRC\README.TXT (where xxxx is the directory name for the Visual C++ product; by default, C:\Program Files\Microsoft Visual Studio\VC98 for Visual C++ version 6.0). The make file exists in the same directory and is named MAKEFILE.
Note You may modify the source and rebuild a DLL version of the MFC library. However, you can redistribute a retail (/release) of your modified library only if you rename it to something other than MFCxx.dll. You may not redistribute the debug version of either the pre-built or custom built debug DLL. Please refer to "MFC Technical Note 33" for more information.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section. This bug has been fixed in Visual Studio 6.0 Service Pack 1.
To obtain this service pack, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/vstudio/Aa718362.aspxFor more information about Visual Studio 6.0 Service Pack 1, click the following article numbers to view the articles in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/193009/ )Visual Studio 6.0 Service Pack 1 Readme
(https://support.microsoft.com/kb/194022/ )Visual Studio 6.0 service packs, what, where, why
(https://support.microsoft.com/kb/194295/ )How to tell that a Visual Studio service pack is installed
The call stack when the access violation occurs should resemble the following:
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Jaganathan Thangavelu, Microsoft Corporation.
Article ID: 193100 - Last Review: February 23, 2014 - Revision: 6.2