Bug 4001

Summary: abstract interface causes incorrect call to static release() of AbstractBase
Product: TAO Reporter: Derek Dominish <derek.dominish>
Component: IDL CompilerAssignee: DOC Center Support List (internal) <tao-support>
Status: NEW ---    
Severity: major    
Priority: P3    
Version: 2.0.6   
Hardware: All   
OS: All   

Description Derek Dominish 2012-01-18 20:16:36 CST
With the following IDL:
module Foo
{
   abstract interface AA  // NOTE the use of 'abstract' here
   {
     void do_aa();
   };
 
   interface BB : AA
   {
     void do_bb();
   };
}

And user code like:

::CORBA::Object_var    obj = .... // get this somehow
::Foo::BB_var          bb_obj = ::Foo::BB::_narrow(obj);
if (::CORBA::is_nil(bb_obj)) {
    ..... // do some error handling
}
//  At this point bb_obj has been released!!  BAD BAD.

Problem is that _var's have static release so the release() is being called against AbstractBase and not polymorphically against Foo::BB::release() because the following generated in FooC.cpp ultimately uses the wrong refcount.
 
void TAO::Objref_Traits<Foo::BB>::release (Foo::BB_ptr p)
{
  ::CORBA::AbstractBase_ptr abs = p;
  ::CORBA::release (abs);
}

IDL Spec(08-01-09 pp96) says release() in this case should be polymorphic - however this will never be with 'static' and pointer reassignment as above.

Please also note <template T> ::CORBA::is_nil(T x) forces the temporary _var copy and subsequent release() showng the problem.  Would it not be better to have argument as ::CORBA::is_nil(const T &x). This should also be more efficient and save the copy of all T types?