Bug 4001 - abstract interface causes incorrect call to static release() of AbstractBase
Summary: abstract interface causes incorrect call to static release() of AbstractBase
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: IDL Compiler (show other bugs)
Version: 2.0.6
Hardware: All All
: P3 major
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks:
 
Reported: 2012-01-18 20:16 CST by Derek Dominish
Modified: 2018-01-15 11:21 CST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?