Home Help Center

Change in Behavior in 2.1 from 2.0

acbellacbell Member Andrew BellOrganization: Iowa State UniversityProject: National Resources Inventory ✭✭
Hi,

My server exits with an assertion in 2.1, but didn't in 2.0, when it is aborted with ctrl-C:

^CAssertion failed: _ref > 0, file ../../include/IceUtil/Shared.h, line 233

I'm sure it is something I am doing wrong, since the demos behave correctly, but I didn't see anything in the release notes that would be an issue. Any info appreciated.

Code:

int main(int argc, char *argv[])
{
ConfLog::Server server;
std::cerr << "Hello there!\n";
return (server.main(argc, argv));
std::cerr << "Goodbye!\n";
}

int ConfLog::Server::run(int argc, char *argv[])
{
_adapter = communicator()->createObjectAdapterWithEndpoints("Server",
"default -p 10501");
_adapter->add(this, Ice::stringToIdentity("Server"));
shutdownOnInterrupt();
_adapter->activate();
cerr << "Ready!\n";
communicator()->waitForShutdown();
return (EXIT_SUCCESS);
}

-- Andrew Bell
[email protected]

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    What is the stack trace?
  • acbellacbell Member Andrew BellOrganization: Iowa State UniversityProject: National Resources Inventory ✭✭
    Stack Trace

    (gdb) where
    #0 0xfed9f81c in _lwp_kill () from /usr/lib/libc.so.1
    #1 0xfed50a24 in raise () from /usr/lib/libc.so.1
    #2 0xfed36ce0 in abort () from /usr/lib/libc.so.1
    #3 0xfed36f80 in _assert () from /usr/lib/libc.so.1
    #4 0x000287ec in IceUtil::Shared::__decRef() (this=0x499d0) at Shared.h:233
    #5 0xff177284 in ?? () from /local/opt/Ice-2.1.0/lib/libIce.so.21
    #6 0x000260b8 in ~Handle (this=0xffbff704) at Handle.h:87
    #7 0x000253a8 in ~Server (this=0xffbff700) at Server.cc:11
    #8 0x0001db70 in main (argc=1, argv=0xffbff78c) at Server.cc:13

    The only thing that I notice that you are doing differently in your samples is that you are dynamically allocating an interface object at the time the adapter is added. In my case the Server class (where run is being called) IS the interface object (on the stack), and "this" is passed as an argument on "adapter->add()". I think that I must have seen the method I used somewhere in your examples or the book, but I don't remember where.

    Thanks as always,

    -- Andrew Bell
    [email protected]
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    You cannot allocate servants on the stack, because they are reference counted. You must allocate them on the heap, i.e., dynamically with new, and assign them to a smart pointer. Please see the Ice manual for further information on reference counting and smart pointers in C++.
Sign In or Register to comment.