Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice::Application within an IceUtil::Tthread

I want to run Ice::Application within an IceUtil::Thread.
I get an exception when exiting the application.

I have included the MSVC7.1 project
Also if you break just before Thread::run exits you will see that the second argument of argv has been zeroed. Bug?

I realise that it is not the most effecient thread usage.

The reasoning is the fastest way to add Ice to an existing app.

Thanks

Alfred

Comments

  • Running this under the debugger, you'll see that the problem is caused by main terminating while your thread is still running, causing memory corruption. You need to use a ThreadPtr variable to hold a reference to the thread, and join with your thread before main() returns.

    Cheers,

    Michi.
  • Thank you for the prompt response.

    The corruption is already there as the IceUtil::Thread::run() method is entered.

    Look at argv[1] it is zeroed!!!!!

    Alfred
  • Sorry the corruption should be Ice::Application::run() method

    im refering to the argv of Thrd::run().



    Alfred
  • that is the corruption happen somewhere between the
    app.main(1, argv, "Ice.config"); call and
    the Ice::Application::run() method being entered.


    There is not much I can do as this is all Ice code.

    Or have I not set something up properly?


    Alfred
  • Have a look at this:

    app.main(1, argv, "Ice.config");

    You are telling main that argv has only one element, not two elements.
    It should be:

    app.main(2, argv, "Ice.config");

    By the way, the C++ standard requires argv to be terminated with a null pointer, so you really should define your dummy argv as:

    char*argv[] = { "test1", "test2", 0 };

    That's because code that parses argv is free to ignore the value of argc and to just loop over the argument vector looking for the terminating null pointer.

    Cheers,

    Michi.