1

We recently upgraded some C++ code from VS2005 -> VS2010.

This C++ code is called RFA_RMDS, and it is an in-house wrapper around the Reuters RFA libraries. This wrapper is used by some C# code in turn. So, to be clear:

    C# -> C++ Wrapper (RFA_RMDS) -> Reuters RFA libraries. 

After the upgrade, the application throws an AccessViolationException (below) when instantiating a RFA client - but only on Windows 7. That is to say, it works fine on Windows XP.

Further, an earlier build of the application that uses the VS2005 version of the C++ wrapper works fine on both Windows 7 and Windows XP.

This leads me to believe that the upgrade is the cause of this exception. However, as I'm not a C++ developer (and we don't really have one right now), I'm at a loss for how to address this.

Some further points:

  • The application runs in 32-bit mode on Windows 7 as the executable has been modified by CorFlags.
  • An earlier build of the application that uses the VS2005 C++ wrapper works fine on both Windows 7 and Win XP.
  • The C++ wrapper targets .NET 2.0, though it used to target .NET 3.5 (which the C# code targets). The problem existed even when it targetted .NET 3.5.
  • The Windows 7 box has the redistributables for Microsoft Visual C++ 2005(x86??/x64), 2008 (x86/x64) and 2010 (x86).

Please let me know if there's any more information I should provide - perhaps also how to get it.

Any tips/suggestions/solutions, even the most basic things would be very much appreciated. Thank you.


Stack Trace


AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

   at std.basic_string,std::allocator >.{dtor}(basic_string\,std::allocator >* )
   at AppLoggerClient.processEvent(AppLoggerClient* , Event* event) in c:\buildagent\work\ef735b7d6bb58dc3\rfa_rmds\rfa_rmds\apploggerclient.cpp:line 70
   at CWM.WindowProc(HWND__* hwnd, UInt32 uMsg, UInt32 wParam, Int32 lParam) in c:\buildagent\work\ef735b7d6bb58dc3\rfa_rmds\rfa_rmds\messageloop.cpp:line 51
   at DispatchMessageW(tagMSG* )
   at DispatchMessage(tagMSG* lpMsg) in c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h:line 3052
   at CWM.run(CWM* ) in c:\buildagent\work\ef735b7d6bb58dc3\rfa_rmds\rfa_rmds\messageloop.cpp:line 89
   at RFA_RMDS.RFA_Frame.Start() in c:\buildagent\work\ef735b7d6bb58dc3\rfa_rmds\rfa_rmds\rfa_frame.cpp:line 122
   at RFA_RMDS.RFA_FrameManager.WorkerThreadFunction() in c:\buildagent\work\ef735b7d6bb58dc3\rfa_rmds\rfa_rmds\rfa_framemanager.cpp:line 126
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

VS2010 C++ Command Line

/I"..\..\RFA-6.3\Include" /I"..\..\RFA-6.3\Include\TIBMsg" /I"..\..\RFA- 6.3\Include\SessionLayer" /I"..\..\RFA-6.3\Include\Common" /I"..\..\RFA-6.3\Include\Logger" /I"..\..\RFA-6.3\Include\Config" /Zi /clr:oldSyntax /nologo /W3 /WX- /O2 /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /EHa /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Release\RFA_RMDS.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc90.pdb" /Gd /TP /FU"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll" /analyze- /errorReport:queue

VS2005 C++ Command Line

/Od /I "..\..\RFA-6.3\Include" /I "..\..\RFA-6.3\Include\TIBMsg" /I "..\..\RFA-6.3\Include\SessionLayer" /I "..\..\RFA-6.3\Include\Common" /I "..\..\RFA-6.3\Include\Logger" /I "..\..\RFA-6.3\Include\Config" /D "WIN32" /D "_DEBUG" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHa /MDd /Yu"stdafx.h" /Fp"Debug\RFA_RMDS.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Zi /clr:oldSyntax /TP /errorReport:prompt /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"

VS2010 Linker Command Line

/OUT:"F:\checkout\gl\global\trunk\client\modules\RFASource\DotNet2.0\RFA_RMDS\Release\RFA_RMDS.dll" /INCREMENTAL:NO /NOLOGO /LIBPATH:"..\..\RFA-6.3\Libs" /DLL "msvcprt.lib" "msvcrt.lib" "ws2_32.lib" "RFA6_Common80.lib" "RFA6_Config80.lib" "RFA6_Logger80.lib" "RFA6_Data80.lib" "RFA6_Connections80.lib" "RFA6_Connections_MD80.lib" "RFA6_SessionLayer80.lib" "AnsiPage80.lib" "libTibMsg.lib" "dacslock.lib" "Shell32.lib" "Shlwapi.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\RFA_RMDS.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"F:\checkout\gl\global\trunk\client\modules\RFASource\DotNet2.0\RFA_RMDS\Release\RFA_RMDS.pdb" /PGD:"F:\checkout\gl\global\trunk\client\modules\RFASource\DotNet2.0\RFA_RMDS\Release\RFA_RMDS.pgd" /LTCG /TLBID:1 /DYNAMICBASE:NO /FIXED:NO /MACHINE:X86 /ERRORREPORT:QUEUE 

VS2005 Linker Command Line

/OUT:"F:\checkout\gl\global\trunk\client\modules\RFASource_VS2005\DotNet2.0\RFA_RMDS\Debug\RFA_RMDS.dll" /INCREMENTAL /NOLOGO /LIBPATH:"..\..\RFA-6.3\Libs" /DLL /MANIFEST /MANIFESTFILE:"Debug\RFA_RMDS.dll.intermediate.manifest" /DEBUG /ASSEMBLYDEBUG /PDB:"f:\checkout\gl\global\trunk\client\modules\RFASource_VS2005\DotNet2.0\RFA_RMDS\Debug\RFA_RMDS.pdb" /MACHINE:X86 /FIXED:No /ERRORREPORT:PROMPT msvcprt.lib msvcrt.lib ws2_32.lib RFA6_Common80.lib RFA6_Config80.lib RFA6_Logger80.lib RFA6_Data80.lib RFA6_Connections80.lib RFA6_Connections_MD80.lib RFA6_SessionLayer80.lib AnsiPage80.lib libTibMsg.lib dacslock.lib Shell32.lib Shlwapi.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
Gant
  • 29,661
  • 6
  • 46
  • 65
ck.
  • 1,056
  • 1
  • 14
  • 25
  • It seems like a `std::string` is throwing an exception from its destructor, which can't be right. Did you recompile all dependent code (ie third party libraries, etc.)? – rubenvb Jun 15 '11 at 19:05
  • You have heap corruption probably due to inconsistent or incompatible linkage somewhere. Rebuild All libraries and projects and also be sure to deploy the correct VC runtime on the target machine if needed, you can download VC redist from microsoft. – AJG85 Jun 15 '11 at 19:14
  • @rubenvb: The only dependent code is Microsoft.VisualC 8.0.0.0 and mscorlib/System/System.Data/System.Xml - all 2.0.0.0. – ck. Jun 15 '11 at 19:21
  • @AJG95: I rebuilt RFA_RMDS from a clean checkout. I also installed Microsoft Visual C++ 2010 x86 redistributable - 10.0.30319 on the Windows 7 box before posting this. And the Windows 7 box also has the redistributables for Microsoft Visual C++ 2005 (/x64), 2008 (x86/x64). – ck. Jun 15 '11 at 19:23
  • P.S. You are not linking objects compiled with different versions of the standard library, are you? – Gene Bushuyev Jun 15 '11 at 22:23
  • Your VC++ 2005 commandline is for a debug build, but your VC++ 2010 commandline is for a release build. Is this intentional? – ildjarn Jun 15 '11 at 22:28
  • @Gene: Sorry, but I'm not a C++ developer so I'm not sure how to verify that. Could you provide some pointers please? – ck. Jun 16 '11 at 13:21
  • @ildjarn: I think that was probably just a mistake in what I pasted here. I previously wasn't even able to start the C# app due to a side-by-side exception when running with a debug build. Therefore, this problem happens with release builds from both VS2005 and VS2010. – ck. Jun 16 '11 at 13:23
  • Try with UAC turned off. It might be an issue with the registry access for the logger. – Tim Mar 05 '12 at 21:39

5 Answers5

2

It is more likely that there is a flaw or latent bug in the code that has been exposed by the upgrade rather than the upgrade itself causing the error. Non-deterministic or undefined behaviour (such as what happens when you dereference an uninitialised pointer for example), is easily likely to change between builds, or execution environment, or compiler, and even between release and debug or when running directly or through a debugger.

I would start by using the debug information you have, such as taking a look at what is happening at (and before) ..\rfa_rmds\apploggerclient.cpp:line 70. It is causing a string object to be deleted, if this is an explicit delete, is the pointer valid? If it is deleting an array of strings has the correct delete[] operator been used? If it is an auto object going out of scope, has some other error (such as a buffer overrun) caused the object to be corrupted?

The easiest way to verify these things is to execute the code in the debugger. However often the change of execution environment can change the behaviour of non-deterministic faults, so why you may no longer get an exception, you may still be able to observe other erroneous behaviour such as writing through an invalid pointer, or data corruption.

Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
Clifford
  • 88,407
  • 13
  • 85
  • 165
1

I had the same problem. It turned out that in one of the native projects, the Platform Toolset was set to v100 instead of v90.

Gonzalo.-
  • 12,512
  • 5
  • 50
  • 82
Stef7
  • 43
  • 5
1

Move rfa log to i.e c:\temp from default app startup location (Windows 7 roaming).

alex
  • 11
  • 1
0

It's a guess, based on two factors: the error is in DLL, and the error is in std::string destructor. That suggests to me that you have a string constructed outside the DLL and attempted to be destroyed inside DLL. Since DLL and application have their own copy of memory manager (unless you use custom allocators working across DLL boundary), any allocation in one and deallocation in another would likely cause a crash. One way to avoid it is to link RTL dynamically everywhere, so you have only one copy of memory manager, or create a custom allocator to avoid multiple memory managers (a lot more work).

Gene Bushuyev
  • 5,512
  • 20
  • 19
0

Is UAC the issue here? Sometimes RFA needs access to the registry or the file system. I am guessing this might be an issue.

Tim
  • 20,184
  • 24
  • 117
  • 214