Archived
This forum has been archived. Please start a new discussion on GitHub.
Ice::initialize(...) crashes with Unhandled Exception
Hi,
I'm trying to initialize Ice::CommunicatorPtr ic in a client application, but it already crashes after a few lines giving me
I'm working on Windows 8.1 with Visual Studio 2012 and ICE 3.5.0. The corresponding code is here:
Ice::CommunicatorPtr ic; is defined in the corresponding header file; it seems that if I create local variables in the c++ file, it works fine, it's just that it crashes if I assign it to the variable defined in the header files. To me this is very weird. I verified that it works with the correct libs like C:\Program Files (x86)\ZeroC\Ice-3.5.0\bin\vc110\iceutil35d.dll'
Any ideas are highly appreciated.
Cheers...
I'm trying to initialize Ice::CommunicatorPtr ic in a client application, but it already crashes after a few lines giving me
Unhandled exception at 0x5A72943D (ice35d.dll) in Demo-debug.exe: 0xC0000005: Access violation reading location 0x00000006.
I'm working on Windows 8.1 with Visual Studio 2012 and ICE 3.5.0. The corresponding code is here:
Ice::InitializationData initData; initData.properties = Ice::createProperties(); ic = Ice::initialize(initData);
Ice::CommunicatorPtr ic; is defined in the corresponding header file; it seems that if I create local variables in the c++ file, it works fine, it's just that it crashes if I assign it to the variable defined in the header files. To me this is very weird. I verified that it works with the correct libs like C:\Program Files (x86)\ZeroC\Ice-3.5.0\bin\vc110\iceutil35d.dll'
Any ideas are highly appreciated.
Cheers...
0
Comments
-
Hi,
We only provide support on the forums for the latest Ice version, can you try with Ice 3.5.1 to see if you still get the issue?
It would be good to see the stack trace of the access violation as well. You should also make sure that you're correctly linking with the right Ice libraries. If you build your program in debug mode, you should be linking with iceutild.lib and iced.lib. See also Why does my application work fine in release mode but crash in debug mode? - ZeroC Documentation - ZeroC.
Cheers,
Benoit.0 -
Hi,
We only provide support on the forums for the latest Ice version, can you try with Ice 3.5.1 to see if you still get the issue?
yes, I upgraded but it does not change anything.It would be good to see the stack trace of the access violation as well. You should also make sure that you're correctly linking with the right Ice libraries. If you build your program in debug mode, you should be linking with iceutild.lib and iced.lib. See also Why does my application work fine in release mode but crash in debug mode? - ZeroC Documentation - ZeroC.
Actually I found the error by looking at the relationships between several libraries included in the project. Assume having a header file a.h with some #ifdef USE_ICE flag in there, something like#ifdef USE_ICE Ice::CommunicatorPtr ic #endif
and you include the file in one project with #define USE_ICE 1 and in another project with #define USE_ICE 0, you will have included different versions of the header file. It compiles fine, because it might not need the variables in the #ifdef clause, but once it is linked, it crashes badly. I introduced the error myself during a merge of multiple versions.
Maybe this helps someone else to track down errors...
Cheers0 -
Hi Clemens,
Each Ice distribution includes only one set of header files, so there is no risk to "include different versions of the header files" ... unless you accidentally use several Ice distributions installed on your computer.
Assuming you're using a single distribution, you need to be careful to use the same flags-or mostly the same flags- when compiling different objects. In particular, when using Ice, you should compile all your objects with either /MDd ("debug") or /MD ("release") and then link with the corresponding Ice libraries (xxxd.lib for debug, xxx.lib for release) for your Visual Studio compiler.
Best regards,
Bernard0