Skip to main content

Problem:

  • Product Name: VisiBroker for C
  • Product Version: All
  • Product Component: C Language Mapping
  • Platform/OS Version: All
  • JDK/Compiler Version: All

The solution for remove_ref() method generates a core dump.
When application is using the following code, it generates a core dump

PortableServer::POA_var poa = _default_POA();
PortableServer::ObjectId_var id = poa->servant_to_id(this);
poa->deactivate_object(id);
this->_remove_ref();

Resolution:

deactivate_object method itself will remove the reference. Hence, there is no need to call the _remove_ref() method. This is a programming pitfall.

To resolve this issue, the call to "_remove_ref()" should be removed in the application.

Further explanation:

  1. When a servant that inherits from PortableServer::RefCountServantBase is created and its ref count is set to 1.
  2. When it is activated with the POA and its ref count is incremented to 2
  3. When PortableServer::POA:: deactivate_object() is called later the reference count is decremented by 1
  4. If the servant becomes deactivated, the _remove_ref is called automatically. This will cause the reference count to zero. The servant is only destroyed when its reference count is 0.

Old KB# 30011

#VisiBrokerforC
#VisiBroker
#Security