[omniORB] (bug) problem with virtual inheritance in IDL-generated classes

Jason Nye jnye@nbnet.nb.ca
Mon Aug 5 17:57:00 2002


--------------Boundary-00=_BNFC3X2QR4LH4006K1ZL
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 8bit

Hello all,

I've just found what looks like is a bug in how omni generates servant
classes from inherited IDL interfaces.

My System:
Platform: Linux 2.4.8
gcc version 3.0.4
omniORB 3.0.5

The problem arises when an exception is thrown from the constructor of a
servant that implements an IDL interface that is derived from another IDL
interface. The small example below shows what I mean. See the attached files
for a fully working test harness that exhibits the problem more clearly.

--- IDL FILE ----

interface A {
    ...
};

interface B : A {
   ...
};

--- END IDL FILE ---

--- C++ Servant & main program ----

...

using namespace std;

class Servant_impl : public virtual POA_B
{
public:
    Servant_impl() { throw runtime_error("dummy error"); }

    ....
};


int main(int argc, char * argv[])
try {
    CORBA::ORB_var orb = ...
    Servant_impl s;
    ....
    orb->run();
    return 0;
}
catch (const exception & ex) {
    cout << "Error: " << ex.what() << endl;
    return -1;
}

--- END C++ Servant & main program ---

The above program will cause segment violation. The interesting thing is that
if Servant_impl was derived from POA_A instead of POA_B, no problem would
result -- the exception would be thrown and caught as expected.

The attached test harness shows that this problem is not a compiler problem
as far as I can tell because I created interface-equivalent base classes for
the servant to derive from and when compiled to use those, no crash occurs.
Please try the test harness to see how it works (much documentation is
included in it). You may have to change some paths in the makefile.

Note that I did not run it through the debugger as I am not very good at all
at using gdb.

Thanks for your help,
Jason.

-------------------------------------------------------



--------------Boundary-00=_BNFC3X2QR4LH4006K1ZL
Content-Type: text/x-c++;
  charset="iso-8859-15";
  name="omni_bug_test.idl"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="omni_bug_test.idl"

I2lmbmRlZiBPTU5JX0JVR19URVNUX0lETAojZGVmaW5lIE9NTklfQlVHX1RFU1RfSURMCgoKLy8v
Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gQSBz
aW1wbGUgSURMIGZpbGUgY29udGFpbmluZyB0d28gaW50ZXJmYWNlczoKLy8gYnVnX3Rlc3RfYmFz
ZSBhbmQgYnVnX3Rlc3RfZGVyaXZlZCB3aGljaCBpcwovLyBkZXJpdmVkIGZyb20gYnVnX3Rlc3Rf
YmFzZS4gVGhlc2UgdHdvIGludGVyZmFjZXMKLy8gYXJlIHVzZWQgaW4gdGhlIHRlc3QgaGFybmVz
cyB0byBzaG93IHRoYXQKLy8gdGhlcmUgc2VlbXMgdG8gYmUgc29tZXRoaW5nIHdyb25nIHdpdGgg
T01OSSBPUkIncwovLyBkZXJpdmF0aW9uIG9mIGludGVyZmFjZXMuCi8vLy8vLy8vLy8vLy8vLy8v
Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCgoKaW50ZXJmYWNlIGJ1Z190ZXN0
X2Jhc2UgewoKICAgIHN0cmluZyBuYW1lKCk7Cgp9OwoKaW50ZXJmYWNlIGJ1Z190ZXN0X2Rlcml2
ZWQgOiBidWdfdGVzdF9iYXNlIHsKCiAgICBzdHJpbmcgbmFtZTIoKTsKCn07CgojZW5kaWYKCg==

--------------Boundary-00=_BNFC3X2QR4LH4006K1ZL
Content-Type: text/x-c++;
  charset="iso-8859-15";
  name="omni_bug_test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="omni_bug_test.cpp"

Ly8KLy8gVGVzdCBoYXJuZXNzIHRvIHNob3cgdGhhdCB0aGVyZSBpcyBhIHByb2JsZW0gd2l0aCB2
aXJ0dWFsCi8vIGluaGVyaXRhbmNlIGluIE9NTkkgT1JCIDMuMC41IElETC1nZW5lcmF0ZWQgY2xh
c3NlcyAoYW4KLy8gZXhjZXB0aW9uIHRocm93biBmcm9tIHRoZSBjb25zdHJ1Y3RvciBvZiBhbiBp
bXBsZW1lbnRlZAovLyBzZXJ2YW50IHdpbGwgY3Jhc2ggdGhlIHByb2dyYW0gaWYgdGhl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VEVBRF9PRl9ERVJJVkVEPT0wCiAgICAgICAgdGhyb3cgcnVudGltZV9lcnJvcigiYnVnIHRlc3Qg
ZXJyb3IiKTsKICAgIH0KCiAgICB2aXJ0dWFsIGNoYXIgKiBuYW1lKCkKI2lmIFVTRV9JRExfQ0xB
U1NFUz09MQogICAgeyByZXR1cm4gQ09SQkE6OnN0cmluZ19kdXAoImJ1Z190ZXN0Iik7IH0KI2Vs
c2UKICAgIHsgcmV0dXJuICJidWdfdGVzdCI7IH0KI2VuZGlmCgogICAgdmlydHVhbCBjaGFyICog
bmFtZTIoKQojaWYgVVNFX0lETF9DTEFTU0VTPT0xCiAgICB7IHJldHVybiBDT1JCQTo6c3RyaW5n
X2R1cCgiYnVnX3Rlc3QyIik7IH0KI2Vsc2UKICAgIHsgcmV0dXJuICJidWdfdGVzdDIiOyB9CiNl
bmRpZgp9OwoKCmludCBtYWluKGludCBhcmdjLCBjaGFyICogYXJndltdKQp0cnkgewogICAgYnVn
X3Rlc3RfaW1wbCBpbXBsOwogICAgcmV0dXJuIDA7Cn0KY2F0Y2ggKGNvbnN0IGV4Y2VwdGlvbiAm
IGVycm9yKSB7CiAgICBjb3V0IDw8ICJlcnJvcjogIiA8PCBlcnJvci53aGF0KCkgPDwgZW5kbDsK
ICAgIHJldHVybiAwOwp9Cgo=

--------------Boundary-00=_BNFC3X2QR4LH4006K1ZL
Content-Type: text/x-makefile;
  charset="iso-8859-15";
  name="Makefile"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Makefile"

IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjCiMgTWFrZWZpbGUgZm9yIExpbnV4CiMj
IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIwoKZXhwb3J0IE9QVElPTlMgPSAtZm5vLXJ0
dGkgLWZuby1lbGlkZS1jb25zdHJ1Y3RvcnMgLU8wIC1ETkRFQlVHCiNleHBvcnQgT1BUSU9OUyA9
IC1nCmV4cG9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