Discussion:
[omniORB] Recursive structures in anys
Michael
2008-03-30 20:21:35 UTC
Permalink
Hello,

I stumbled over an issue regarding recursive structures in IDLs. Basically it is the same
issue posted by Renzo Tomaselli backin 2005 (see below), but I couldn't find any
indication that this has ever been fixed.

In contrast to Renzo I'm not building a DynAny but I'm just sending the recursive struct
inside of an any (the process dies on signal 6 somewhere inside of omniorb).

pseudoIDL:
struct Message
{
long id;
any payload;
};

struct Entry;
typedef sequence<Entry> EntrySeq;
struct Entry
{
string name;
EntrySeq entries;
};

pseudocode:
Entry e;
e.name="test";
e.entries.length(1);
e.entries[0].name="test2";

Message m;
m.id = 1;
m.payload <<= e;

factory->doremotecall(m);
==>
pure virtual method called
terminate called without an active exception
Abort trap: 6 (core dumped)

The anonymous construct works ok:
struct Entry
{
string name;
sequence<Entry> entries;
};

but omniidl gives a warning:
"Warning: Anonymous sequences for recursive structures are deprecated. Use a forward
declaration instead".

regards
michael

-- Post of Renzo Thu Apr 7 21:00:20 BST 2005

Hi,
it's me again. Indeed, the alternative construction:

struct JobNode {
sequence<JobNode, 2>next;
};
typedef sequence<JobNode, 2> JobNodeList;

works fine, since the failing alias is moved outside. Btw, this is the
common form of all OMG recursion examples.
However, omniidl complains saying "Warning: Anonymous sequences for
recursive structures are deprecated. Use a forward declaration instead".
Just a warning, but exactly what is not actually working in dynamic
procedures.

Renzo
Hi all,
I have some problems while building a recursive typecode
dynamically, while everythings works file from standard idl (e.g.
static) usage.
typedef sequence<JobNode, 2> JobNodeList;
struct JobNode {
JobNodeList next;
};
CORBA::TypeCode_var tcNode =
orb->create_recursive_tc("IDL:/JobNode:1.0");
CORBA::TypeCode_var tcSeq = orb->create_sequence_tc(2, tcNode);
CORBA::TypeCode_var tcAlias =
orb->create_alias_tc("IDL:/JobNodeList:1.0", "JobNodeList", tcSeq);
...
the last statement throws an exception from method NP_resolved(),
since it tries to match JobNodeList vs. Node, failing of course.
Indeed JobNode would be resolved one step out. I guess a nested
definition would work as a workaround (I'll try it later), however I
feel this behavior fighting against the correct behavior while derived
from static idl.
Any suggestion ? Thanks,
Renzo Tomaselli
Duncan Grisby
2008-03-31 16:32:21 UTC
Permalink
Post by Michael
I stumbled over an issue regarding recursive structures in
IDLs. Basically it is the same issue posted by Renzo Tomaselli backin
2005 (see below), but I couldn't find any indication that this has
ever been fixed.
The issue Renzo reported was fixed in April 2005.

Can you post a complete example that shows the problem? And what
version of omniORB are you using?

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Michael
2008-03-31 20:13:10 UTC
Permalink
Hi Duncan,

I'm (still) using omniORB 4.1.0 on FreeBSD 6.2 gcc 3.4.6.

I tried to come up with a minimum example.
Type "make working" to compile the anonymous (working) version, or
"make broken" to do the typedefed (broken) version.

Start server:
./TestServer
<outputs server ior>

Start client:
./TestClient <server ior>

The working client causes:
"Received call"
on the server side.

The broken client doesn't crash in this example, but causes:
omniORB: From endpoint: giop:tcp:192.168.250.2:55048. Detected GIOP 1.2 protocol error in
input message. giopImpl12.cc:863. Connection is closed.

..on the server side (it doesn't matter if server was compiled working or broken).
(in the muhc more complicated production code it still causes Signal 6 - so I assume there
must be something broken in the marshalling code?!?)

cheers
michael
Post by Duncan Grisby
Post by Michael
I stumbled over an issue regarding recursive structures in
IDLs. Basically it is the same issue posted by Renzo Tomaselli backin
2005 (see below), but I couldn't find any indication that this has
ever been fixed.
The issue Renzo reported was fixed in April 2005.
Can you post a complete example that shows the problem? And what
version of omniORB are you using?
Cheers,
Duncan.
-------------- next part --------------
CC=g++

working:
omniidl -bcxx -Wbh=.h -Wbs=.C -Wba -Wbd=_dyn.C Test.idl
$(CC) -pthread -I/usr/local/include -c -o Test.o Test.C
$(CC) -pthread -I/usr/local/include -c -o Test_dyn.o Test_dyn.C
$(CC) -pthread -I/usr/local/include -c -o TestClient.o TestClient.C
$(CC) -pthread -I/usr/local/include -c -o TestServer.o TestServer.C
$(CC) -pthread -L/usr/local/lib -lomniORB4 -lCOSNotify4 Test.o Test_dyn.o TestClient.o -o TestClient
$(CC) -pthread -L/usr/local/lib -lomniORB4 -lCOSNotify4 Test.o Test_dyn.o TestServer.o -o TestServer

broken:
omniidl -bcxx -Wbh=.h -Wbs=.C -Wba -Wbd=_dyn.C -DBROKEN=1 Test.idl
$(CC) -pthread -I/usr/local/include -c -o Test.o Test.C
$(CC) -pthread -I/usr/local/include -c -o Test_dyn.o Test_dyn.C
$(CC) -pthread -I/usr/local/include -c -o TestClient.o TestClient.C
$(CC) -pthread -I/usr/local/include -c -o TestServer.o TestServer.C
$(CC) -pthread -L/usr/local/lib -lomniORB4 -lCOSNotify4 Test.o Test_dyn.o TestClient.o -o TestClient
$(CC) -pthread -L/usr/local/lib -lomniORB4 -lCOSNotify4 Test.o Test_dyn.o TestServer.o -o TestServer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.idl
Type: text/x-idl
Size: 542 bytes
Desc: not available
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080331/b5866a87/Test.bin
-------------- next part --------------
#include <iostream>
#include "Test.h"

int main(int argc, char** argv)
{
if (argc < 2) return 254;
try
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
Test::List mylist;
mylist.entries.length(1);
mylist.entries[0].entries.length(1);

Test::Envelope cinfo;
cinfo.payload <<= mylist;

CORBA::Object_var obj = orb->string_to_object(argv[1]);
Test::TestServer_var ts = Test::TestServer::_narrow(obj);
ts->call(cinfo);
}
catch(CORBA::Exception& e)
{
std::cerr << "CORBA Exception " << typeid(e).name() << std::endl;
}
catch(...)
{
std::cerr << "Exception" << std::endl;
}
}
-------------- next part --------------
#include <iostream>
#include "Test.h"

class TestServer_impl: virtual public POA_Test::TestServer, virtual public PortableServer::RefCountServantBase
{
public:
TestServer_impl() {}

void call(const Test::Envelope& e)
{
std::cout << "Received call" << std::endl;
}
};


int main(int argc, char** argv)
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
PortableServer::POAManager_var pman = root_poa->the_POAManager();
PortableServer::LifespanPolicy_var lifespan = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
CORBA::PolicyList policy_list;
policy_list.length(2);
policy_list[0] = PortableServer::LifespanPolicy::_duplicate(lifespan);
policy_list[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign);

PortableServer::POA_var TestServer_poa = root_poa->create_POA("TestServer", pman, policy_list);

TestServer_impl impl;
PortableServer::ObjectId_var implId = PortableServer::string_to_ObjectId("TestServer");
TestServer_poa->activate_object_with_id(implId, &impl);

CORBA::Object_var test_obj = impl._this();
CORBA::String_var ior = orb->object_to_string(test_obj);
std::cout << ior << std::endl;
pman->activate();
orb->run();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recursive.tgz
Type: application/x-compressed-tar
Size: 1386 bytes
Desc: not available
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080331/b5866a87/recursive.bin
Michael
2008-04-01 03:10:15 UTC
Permalink
Hi,

things are getting worse, when using the anonymous approach I get the following exception
on shutdown in every servant that has been touched by the Any:

omniORB: Assertion failed. This indicates a bug in the application
using omniORB, or maybe in omniORB itself.
file: ../../../.././../src/lib/omniORB/dynamic/typecode.cc
line: 1230
info: CORBA::TypeCode::PR_is_valid(o)
terminate called after throwing an instance of 'omniORB::fatalException'
Abort trap: 6 (core dumped)

Our setup is: client->gateway->destination, gateway only receives requests, checks for the
repositoryid and forwards them to destination. It does not look at the content
explicitely. Both gateway and destination show the error above.

This reminds me of dealing with DynAny to serialize anys. I was able to produce similar
exceptions when not dealing with typecodes correctly (can't remember the exact details).

For the meantime I will rewrite our code to flatten out the structures , but I think this
might be worth fixing anyway :) (approved: using flat structures fixes our issues, I
couldn't provoke this behaviour in the testcode I sent you earlier though).

cheers
michael
Post by Michael
Hi Duncan,
I'm (still) using omniORB 4.1.0 on FreeBSD 6.2 gcc 3.4.6.
I tried to come up with a minimum example.
Type "make working" to compile the anonymous (working) version, or
"make broken" to do the typedefed (broken) version.
./TestServer
<outputs server ior>
./TestClient <server ior>
"Received call"
on the server side.
omniORB: From endpoint: giop:tcp:192.168.250.2:55048. Detected GIOP 1.2 protocol error in
input message. giopImpl12.cc:863. Connection is closed.
..on the server side (it doesn't matter if server was compiled working or broken).
(in the muhc more complicated production code it still causes Signal 6 - so I assume there
must be something broken in the marshalling code?!?)
cheers
michael
Post by Duncan Grisby
Post by Michael
I stumbled over an issue regarding recursive structures in
IDLs. Basically it is the same issue posted by Renzo Tomaselli backin
2005 (see below), but I couldn't find any indication that this has
ever been fixed.
The issue Renzo reported was fixed in April 2005.
Can you post a complete example that shows the problem? And what
version of omniORB are you using?
Cheers,
Duncan.
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Duncan Grisby
2008-04-08 16:25:57 UTC
Permalink
Post by Michael
I'm (still) using omniORB 4.1.0 on FreeBSD 6.2 gcc 3.4.6.
I tried to come up with a minimum example.
Type "make working" to compile the anonymous (working) version, or
"make broken" to do the typedefed (broken) version.
I tried your example with the current CVS version of omniORB, on Linux,
and it worked without any errors for me. I ran it under valgrind, and
that didn't report any memory management problems either.

Please can you try with omniORB 4.1.2, or the current CVS snapshot?
There is at least one bug fixed since 4.1.0 that could be relevant. If
you still see problems, it must be a problem specific to your platform /
compiler.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Michael
2008-04-08 23:45:52 UTC
Permalink
Post by Duncan Grisby
Post by Michael
I'm (still) using omniORB 4.1.0 on FreeBSD 6.2 gcc 3.4.6.
I tried to come up with a minimum example.
Type "make working" to compile the anonymous (working) version, or
"make broken" to do the typedefed (broken) version.
I tried your example with the current CVS version of omniORB, on Linux,
and it worked without any errors for me. I ran it under valgrind, and
that didn't report any memory management problems either.
Please can you try with omniORB 4.1.2, or the current CVS snapshot?
There is at least one bug fixed since 4.1.0 that could be relevant. If
you still see problems, it must be a problem specific to your platform /
compiler.
Cheers,
Duncan.
Hi Duncan,

the Problem also exists on Linux using 4.1.0.
Using 4.1.1 the first problem reported seems to be fixed.
The second problem, which turned out to appear when sending an anonymous recursive
structure that includes an ENUM type (see attached idl) still exists under 4.1.1 but has
gone under 4.1.2. So I would assume all of this fixed and ok (at least for my testcase).

cheers
michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.idl
Type: text/x-idl
Size: 639 bytes
Desc: not available
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080408/bf69d098/Test.bin
Loading...