Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 04-22-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
Change in Behavior in 2.1 from 2.0

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
andrew.bell.ia@gmail.com
Reply With Quote
  #2 (permalink)  
Old 04-22-2005
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
What is the stack trace?
Reply With Quote
  #3 (permalink)  
Old 04-22-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
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
andrew.bell.ia@gmail.com
Reply With Quote
  #4 (permalink)  
Old 04-22-2005
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
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++.

Last edited by marc : 04-22-2005 at 02:31 PM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable Ice's reestablish-connection behavior ? rc_hz Help Center 4 08-31-2006 11:25 AM
Change IP address during runtime wgwolf Help Center 1 05-31-2006 05:35 AM
Application Helper class and shutdown behavior RyanFogarty Comments 2 11-30-2004 01:30 PM
IceStorm change in 1.1.0? vukicevic Help Center 1 05-28-2003 07:27 PM
Why allow undefined behavior ? Mogens Hansen Comments 2 02-19-2003 05:46 PM


All times are GMT -4. The time now is 10:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.