CPP 1.3 NO IDEA Avatar
  1. OMG Issue

CPP13 — Variable-length out params and exceptions

  • Key: CPP13-42
  • Legacy Issue Number: 3539
  • Status: open  
  • Source: Triodia Technologies Pty Ltd ( Michi Henning)
  • Summary:

    the spec is currently not terribly clear about the server's responsibilities
    when throwing an exception from an operation that has a variable-length
    out param.

    The intent of the spec is that the server is responsible for deleting
    the memory it allocated to an out param before it throws an exception:

    // Correct implementation
    void
    Foo_impl::
    op(CORBA::String_out out_p) throw(CORBA::SystemException)

    { CORBA::String_var tmp = CORBA::string_dup("Hello"); bar(); // bar() may throw out_p = tmp._retn(); // No leak, even if bar() throws }

    // Incorrect implementation
    void
    Foo_impl::
    op(CORBA::String_out out_p) throw(CORBA::SystemException)

    { out_p = CORBA::string_dup("Hello"); bar(); // Leak if bar() throws }

    However, the spec never states this clearly. In fact, it sort of says
    the opposite. On page 1-110, table item 3:

    To maintain local/remote transparency, the caller must always
    release the returned storage, regardless of whether the callee
    is located in the same address space as the caller or is located
    in a different address space.

    There is no mention here of what should happen in the presence of exceptions.

    I think it would be nice to clarify that the skeleton will never look
    at an out param in the presence of exceptions and that the operation
    implementation is responsible for deallocating memory in this case.

  • Reported: CPP 1.1 — Tue, 11 Apr 2000 04:00 GMT
  • Updated: Fri, 6 Mar 2015 20:57 GMT