Home Help Center

Unhandled Exception

rogiovrogiov Member Roberto GiovannelliOrganization: prexis spaProject: cip driver
Hi,

In a complex c++ multithread application that uses MFC, Winpcap and many other libraries When I Execute/Debug the follow C++ code in VC6:

Ice::CommunicatorPtr ic;
InputReceiverPrx inputServer;
int status = 0;
argc = 0;

try {
ic = Ice::initialize(argc, 0);
Ice::ObjectPrx base = ic->stringToProxy("InputReceiver:tcp -h 172.16.0.53 -p 10000");
inputServer = InputReceiverPrx::checkedCast(base);

if (!inputServer)
throw "Invalid proxy";

string s = inputServer->getInfo();
AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);

} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}



The following message appear:

"Unhandled Exception (STLPORT_VC6_STLDEBUG46.DLL):0xC0000005:Acces Violation"

the istruction causing the error is

inputServer->getInfo();

I have no compile or link problems, but a runtime error!!

The same souce code work Properly in Another simple console application!!

The settings of visual c++ project that I use for the simple application, can not be set in the complex application Because of links problems with other libraries.

I use Microsoft Visual C + + 6.0 and Ice-3.0.1-VC60.

Thanks in advance for your help

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Roberto,

    This sounds like a problem with the compiler / linker settings for your more complicated application. Could you describe them some more? Or post you project file?
    It could be for example a C++ runtime mismatch; or maybe you didn't enable RTTI.

    Also, please note that we only provide free support on these forums for the latest version of Ice. Is there any reason for not upgrading to Ice 3.2.1?

    Cheers,
    Bernard
  • rogiovrogiov Member Roberto GiovannelliOrganization: prexis spaProject: cip driver
    Hi Bernard,

    First of all, Excuse me for my BaD English!!

    The application is a particular ethernet driver that in the original version
    transferred data to a SCADA (HMI) (wonderware Intouch).
    The data are read by the network via the wipcap library (Windows Packet Capture Library).

    It was also used SmartState, Most Popular UML CASE Tool State Chart which Supports Sub,
    Concurrent & Nested State Machines with 100% State Machine Code Generation in C++,Java,C and C#,
    for the management of a particular ethernet format packages (TP4).

    In the new version I should send the data, instead to the SCADA Intouch,
    to a server ICE (inputServer).

    RTTI is enabled (in Project's Option there is /GR)

    I use Ice-3.0.1 because all ice clients that I developed speak properly with Ice sever (inputServer),
    which wasn't developed by me, runs under Linux and uses ICE-3.01 for linux.

    If I upgrade ICE client to version 3.2.1, can I talk to a server written with Ice 3.0.1?

    This is the .Dsp project file (Not all the file But only the options for message size problems):

    # Microsoft Developer Studio Project File - Name="CIPdriver" - Package Owner=<4>
    # Microsoft Developer Studio Generated Build File, Format Version 6.00
    # ** DO NOT EDIT **

    # TARGTYPE "Win32 (x86) Application" 0x0101

    CFG=CIPdriver - Win32 Debug
    !MESSAGE This is not a valid makefile. To build this project using NMAKE,
    !MESSAGE use the Export Makefile command and run
    !MESSAGE
    !MESSAGE NMAKE /f "CIPdriver.mak".
    !MESSAGE
    !MESSAGE You can specify a configuration when running NMAKE
    !MESSAGE by defining the macro CFG on the command line. For example:
    !MESSAGE
    !MESSAGE NMAKE /f "CIPdriver.mak" CFG="CIPdriver - Win32 Debug"
    !MESSAGE
    !MESSAGE Possible choices for configuration are:
    !MESSAGE
    !MESSAGE "CIPdriver - Win32 Release" (based on "Win32 (x86) Application")
    !MESSAGE "CIPdriver - Win32 Debug" (based on "Win32 (x86) Application")
    !MESSAGE

    # Begin Project
    # PROP AllowPerConfigDependencies 0
    # PROP Scc_ProjName "CIPdriver"
    # PROP Scc_LocalPath ".."
    CPP=cl.exe
    MTL=midl.exe
    RSC=rc.exe

    !IF "$(CFG)" == "CIPdriver - Win32 Release"

    # PROP BASE Use_MFC 6
    # PROP BASE Use_Debug_Libraries 0
    # PROP BASE Output_Dir "Release"
    # PROP BASE Intermediate_Dir "Release"
    # PROP BASE Target_Dir ""
    # PROP Use_MFC 6
    # PROP Use_Debug_Libraries 0
    # PROP Output_Dir "Release"
    # PROP Intermediate_Dir "Release"
    # PROP Ignore_Export_Lib 0
    # PROP Target_Dir ""
    F90=df.exe
    # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
    # ADD CPP /nologo /MDd /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../include/stlport" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "_DEBUG" /D "_MT" /FAs /YX"stdafx.h" /FD /c
    # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
    # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
    # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
    # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
    BSC32=bscmake.exe
    # ADD BASE BSC32 /nologo
    # ADD BSC32 /nologo
    LINK32=link.exe
    # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
    # ADD LINK32 iced.lib iceutild.lib libmysql.lib ..\libs\winpcap\wpcap.lib ..\libs\winpcap\packet.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 /nologo /stack:0x400000,0x80000 /subsystem:windows /incremental:yes /map /debug /machine:I386 /nodefaultlib:"MSVCRT" /pdbtype:sept /libpath:"C:\Ice-3.0.1-VC60\lib"
    # SUBTRACT LINK32 /pdb:none
    # Begin Special Build Tool
    SOURCE="$(InputPath)"
    PostBuild_Cmds=copy /B .\release\*.exe ..\runtime\*.exe /V
    # End Special Build Tool

    !ELSEIF "$(CFG)" == "CIPdriver - Win32 Debug"

    # PROP BASE Use_MFC 6
    # PROP BASE Use_Debug_Libraries 1
    # PROP BASE Output_Dir "Debug"
    # PROP BASE Intermediate_Dir "Debug"
    # PROP BASE Target_Dir ""
    # PROP Use_MFC 6
    # PROP Use_Debug_Libraries 1
    # PROP Output_Dir "Debug"
    # PROP Intermediate_Dir "Debug"
    # PROP Ignore_Export_Lib 0
    # PROP Target_Dir ""
    F90=df.exe
    # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
    # ADD CPP /nologo /MDd /vmg /GR /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_AFXDLL" /FAs /FR /FD /GZ /EHs /c
    # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
    # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /Oicf /win32
    # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
    # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
    BSC32=bscmake.exe
    # ADD BASE BSC32 /nologo
    # ADD BSC32 /nologo
    LINK32=link.exe
    # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
    # ADD LINK32 iced.lib iceutild.lib libmysql.lib ..\libs\winpcap\wpcap.lib ..\libs\winpcap\packet.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 /version:1.5 /stack:0x400000,0x80000 /subsystem:windows /map /debug /machine:I386
    # SUBTRACT LINK32 /pdb:none /incremental:no
    # Begin Special Build Tool
    SOURCE="$(InputPath)"
    PostBuild_Cmds=copy /B .\debug\*.exe ..\runtime\*.exe /V
    # End Special Build Tool

    !ENDIF


    # Begin Custom Build - SS Compile
    InputPath=..\framework\TP4.smc
    InputName=TP4

    BuildCmds= \
    "..\libs\smartstate\SmartState\BIN\smc2cpp.exe" $(InputPath)

    "..\framework\$(InputName)SS.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
    $(BuildCmds)

    "..\framework\$(InputName)SS.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
    $(BuildCmds)
    # End Custom Build

    !ELSEIF "$(CFG)" == "CIPdriver - Win32 Debug"

    # Begin Custom Build - SS Compile
    InputPath=..\framework\TP4.smc
    InputName=TP4

    BuildCmds= \
    "..\libs\smartstate\SmartState\BIN\smc2cpp.exe" $(InputPath)

    "..\framework\$(InputName)SS.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
    $(BuildCmds)

    "..\framework\$(InputName)SS.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
    $(BuildCmds)
    # End Custom Build

    !ENDIF

    # End Group
    # End Target
    # End Project


    If you need the whole project, I can send it yourself,
    but you need to several libraries to compile and link (winpcap and smartate).

    Thank you very much

    Roberto
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Roberto,

    I don't see any problem with your debug build flags. Did you also setup your Visual C++ 6 environment to include <ice-home>\include\stlport before anything else?
    You could also try to add a catch(const std::exception&) block to see if you get more information.

    It could be an incompatibility between STLPort and the built-in Microsoft standard library used by one of your third-parties (assuming at least one of them is written in C++). Can you upgrade to a newer Microsoft C++ compiler? With Microsoft Visual Studio 2003 and 2005, Ice uses the built-in standard library.

    Finally, please upgrade to Ice 3.2.1. It includes new features and bug fixes, and is totally interoperable with earlier Ice releases (on any platform). And you can take advantage of our free support :).

    Best regards,
    Bernard
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    You should carefully review your build flags & libraries again. I notice your release build flags are wrong -- you are using the debug libraries when you should not. Take a look at the section "# ADD LINK32 iced.lib iceutild.lib" -- this must be ice.lib and iceutil.lib, the *d.lib are the debug libraries and will therefore use the debug runtime which is incompatible with the release libraries.

    If you continue to run into this issue then run your application in a debugger. Start the application and then open "Debug/Exceptions" and tell the debugger to break on access violations. When the access violation is hit the debugger will break and let you see exactly where the problem occurs.
  • rogiovrogiov Member Roberto GiovannelliOrganization: prexis spaProject: cip driver
    Thank you infinitely Matthew and Bernard!!

    The problem was caused by libraries *d.lib.


    Thanks again!

    Roberto
Sign In or Register to comment.