Thread: [Orbit-python-list] (in Object obj) marshalling error
Status: Inactive
Brought to you by:
tack
From: Christian R. R. <ki...@as...> - 2001-01-23 00:24:18
|
Using orbit-python (no idea if we're getting a Orbit error, however) and a simple interface NamingObject { void bind(in Object obj); }; interface, I have the following issues: 1) Calling bind with a simple object reference: [...] class Foo: pass a=Foo() nc.bind(a) TypeError: Failed to marshal: Object Reference () even though a _is_ an object reference. 2) Didn't work? Ok, let's try a stringified IOR: nc.bind(orb.object_to_string(a)) CORBA.SystemException: IDL:CORBA/MARSHAL:1.0: IDL:CORBA/MARSHAL:1.0 Hmm. I wonder why I get a different message? 3) Let's do something dumb now: nc.bind(1) TypeError: Failed to marshal: Object Reference () Ok, same error as my first non-ior attempt. Passing any other object gets me the same error (strings, etc). 4) And what about nc.bind(orb.object_to_string(1)) Segmentation fault Hmm, boom. Orbit-python or plain Orbit? The practical effect of this is that it's impossible to use orbit-python with the Orbit nameserver as of now. We simply can't bind the servers to names because bind() takes an object parameter. I've cut out the offending code and will start looking for the issue; in the meantime, if Jason has any ideas.. :-) Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |
From: Roland M. <ma...@ec...> - 2001-01-23 08:37:23
|
Christian Robottom Reis (2001-01-22 22:24:31 -0200) : > Using orbit-python (no idea if we're getting a Orbit error, however) and a > simple > > interface NamingObject { > void bind(in Object obj); > }; > > interface, I have the following issues: > > 1) Calling bind with a simple object reference: > > [...] > class Foo: > pass > a=Foo() > nc.bind(a) > > TypeError: Failed to marshal: Object Reference () > > even though a _is_ an object reference. Hm. Is is a Python object reference, I'm not sure it's a CORBA object reference. > 2) Didn't work? Ok, let's try a stringified IOR: > > nc.bind(orb.object_to_string(a)) > > CORBA.SystemException: IDL:CORBA/MARSHAL:1.0: IDL:CORBA/MARSHAL:1.0 > > Hmm. I wonder why I get a different message? For the same reason. a is not of a type known by ORBit. > 3) Let's do something dumb now: > > nc.bind(1) > > TypeError: Failed to marshal: Object Reference () Same again. You can only marshal objects that are defined in a CORBA interface. You should add an interface like: interface Foo { attribute string bar ; } ; Then you need to make your Python Foo class a subclass of Your_module__POA.Foo: class Foo (Your_module__POA.Foo): def __init__ (self): self.bar = "Initial string" Only then will ORBit-Python know how to marshal your Foo objects. > 4) And what about > > nc.bind(orb.object_to_string(1)) > > Segmentation fault > > Hmm, boom. Orbit-python or plain Orbit? That's a tricky question, and a nasty bug anyway. I'll try to have a look sometime. > The practical effect of this is that it's impossible to use > orbit-python with the Orbit nameserver as of now. I'm not so sure. It's not like I have done it, but I would be more convinced if you could retry with CORBA objects. > We simply can't bind the servers to names because bind() takes an > object parameter. Yep. A CORBA object, not a Python object. Roland. -- Roland Mas Et c'est tellement plus mignon de se faire traiter de con en chanson... -- in En chantant (Michel Sardou) |
From: Christian R. R. <ki...@as...> - 2001-01-23 14:57:39
|
On 23 Jan 2001, Roland Mas wrote: > > TypeError: Failed to marshal: Object Reference () > > > > even though a _is_ an object reference. > > Hm. Is is a Python object reference, I'm not sure it's a CORBA > object reference. According to the CORBA Python Mappings, If an operation expects parameters of the IDL Object type, any Python object representing an object reference might be passed as a value. So I'm passing as a parameter a Python Object which I've just instantiated from a class that inherits from a __POA class, so it _is_ a Corba Object. > > Hmm. I wonder why I get a different message? > > For the same reason. a is not of a type known by ORBit. A different message, for the same reason? What I mean is that _any_ object that I pass - be it local, Corba, or simple number/string objects get me the same error. However, passing an IOR string gets me a different one? Sounds strange, but I haven't looked at the source yet. > You should add an interface like: > > interface Foo { > attribute string bar ; > } ; Oh, I do have an interface for my Corba Object which I'm passing as a parameter. The purpose of this exercise is binding an object - a factory in this case - to the namingservice. The bind() call takes an Object as a parameter, so I instantiate a factory and pass it on. However, the marshalling breaks, and it breaks with any object I push through as well. > > The practical effect of this is that it's impossible to use > > orbit-python with the Orbit nameserver as of now. > > I'm not so sure. It's not like I have done it, but I would be more > convinced if you could retry with CORBA objects. They were Corba Objects. I was incomplete in my explanation, and I'm sorry, but the objects I was passing initially are Corba Objects with interfaces defined in the IDL. And they get ht the exact same error as plain Python objects, so it's strange. Thanks a lot for the reply. Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |
From: Jason T. <ta...@li...> - 2001-01-23 17:59:56
|
> So I'm passing as a parameter a Python Object which I've just instantiated > from a class that inherits from a __POA class, so it _is_ a Corba Object. As Roland pointed out, Foo is a Python object, not derived from the __POA class. ORBit-Python has no idea what to do with that object, even if it weren't broken. ;) Basically ORBit-Python doesn't seem to handle generic object references very well (at all) right now. I made a change to my local copy that _seems_ to correct the problem, but the change was so trivial that it can't possibly be right, so I'll want to test it a little further before I commit it. > According to the CORBA Python Mappings, > > If an operation expects parameters of the IDL Object type, any > Python object representing an object reference might be passed as > a value. I think you might have misunderstood what this says, or maybe it's a little ambiguous. A Python object representing an object reference looks like: class Foo(CosNaming__POA.NamingContext): pass a = Foo() a._this() # implicit activation ref = poa.servant_to_reference(a) # ref is a python object that represents the object reference print ref Yields: <CosNaming.NamingContext object at 80e2518> I don't think the mapping specification says that in your example bind(1) should work. 1 is not a CORBA object. I think, though, it might be a nice feature if ORBit-Python coerced servants into object references in this situation. > A different message, for the same reason? What I mean is that _any_ object > that I pass - be it local, Corba, or simple number/string objects get me No, a different message for a different reason. I'll go through your examples from your original email and explain what happened: > 1) Calling bind with a simple object reference: > [...] > class Foo: > pass > a=Foo() > nc.bind(a) > TypeError: Failed to marshal: Object Reference () Like I said earlier, ORBit-Python doesn't handle generic object references. However, even if it did, this wouldn't work because Foo doesn't inherit a POA class. > 2) Didn't work? Ok, let's try a stringified IOR: > nc.bind(orb.object_to_string(a)) > CORBA.SystemException: IDL:CORBA/MARSHAL:1.0: IDL:CORBA/MARSHAL:1.0 I'm not entirely sure what happened here, but my guess is 'a' wasn't a valid IOR (such as, for example, if it has trailing newlines and you're not using the latest CVS version). This exception was probably raised from object_to_string, not within the bind stub. > 3) Let's do something dumb now: > nc.bind(1) > TypeError: Failed to marshal: Object Reference () Well again, ORBit-Python won't handle the objref properly, but in this case you're not passing it a CORBA object. It sounds to me like you're mixing up the Any type with the Object type. > 4) And what about > nc.bind(orb.object_to_string(1)) > Segmentation fault Okay, well this is a bug in ORBit-Python, to be sure. ORBit-Python's object_to_string doesn't do any sanity checking. ORBit-Python happily passes this over to ORBit, which in turn happily tries to dereference this value (thinking it is a CORBA_Object) and kaboom. This is documented actually in the source code, in CORBA_ORB.c: if (PyArg_ParseTuple(args, "O", &obj)) { // validate obj == CORBA_PyObject s = CORBA_ORB_object_to_string(self->obj, obj->obj, &self->ev); [ ... ] It's just missing a FIXME :) So, here the segfault happens inside object_to_string, not bind(). Anyway thanks for identifying this bug. I'll hopefully commit some sort of fix by the end of the day. :) Jason. |
From: Christian R. R. <ki...@as...> - 2001-01-23 23:18:08
|
On Tue, 23 Jan 2001, Jason Tackaberry wrote: > > [...] > > class Foo: > > pass > > a=Foo() > > nc.bind(a) > > TypeError: Failed to marshal: Object Reference () > > Like I said earlier, ORBit-Python doesn't handle generic object > references. However, even if it did, this wouldn't work because Foo > doesn't inherit a POA class. You're right. My example was stupid. The problem I have is that ATM you can't even pass a Corba Object as a parameter -- you get the exact same error. As a simple example: module Bar { interface Foo { void bind (in Object a); }; }; and the following servant: #!/usr/bin/env python import CORBA import Bar,Bar__POA class Foo(Bar__POA.Foo): def bind(self,i): print i o=CORBA.ORB_init([],CORBA.ORB_ID) p=o.resolve_initial_references("RootPOA") f=Foo() f._this() ref = p.servant_to_reference(f) print o.object_to_string(ref) p._get_the_POAManager().activate() o.run() produce the same TypeError: Failed to marshal: Object Reference () when a client like this tries to call bind: #!/usr/bin/env python import sys,CORBA, Bar, Bar__POA o=CORBA.ORB_init([],CORBA.ORB_ID) f=o.string_to_object(sys.argv[1]) f.bind(f) Okay, so I used f as a parameter to itself: it should work, no? And f _is_ a reference to a Corba object. > I'm not entirely sure what happened here, but my guess is 'a' wasn't a > valid IOR (such as, for example, if it has trailing newlines and you're > not using the latest CVS version). Actually, it was a valid IOR and ior-decode indicated it as such. I'm using CVS orbit-python (and I check to see if it's been updated daily too *grin*) But I can't seem to reproduct this right now. > Well again, ORBit-Python won't handle the objref properly, but in this > case you're not passing it a CORBA object. It sounds to me like you're > mixing up the Any type with the Object type. No, just trying (brokenly) to illustrate that I get the same error message whether it's a Corba Object or a plain Python object. My example class Foo: pass should really have been class Foo(Bar__POA.Foo) pass but it still doesn't work, regardless :-) > It's just missing a FIXME :) > So, here the segfault happens inside object_to_string, not bind(). Ok, this is reasonable, I was just wondering. :-) Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |
From: Jason T. <ta...@li...> - 2001-01-24 00:02:45
|
> You're right. My example was stupid. The problem I have is that ATM you > can't even pass a Corba Object as a parameter -- you get the exact same > error. As a simple example: Right. It's a bug. :) I've little free time until tomorrow night, so I may not commit a fix until then. But give this a try: in marshal.c, line 473 (or there abouts, I'm a little out of sync), change: if (glue) to if (glue || !strcmp(tc->repo_id, "")) Like I said, this is so trivial it can't possibly work, right? :) Let me know. Cheers, Jason. |
From: Christian R. R. <ki...@as...> - 2001-01-25 22:40:18
|
On Tue, 23 Jan 2001, Jason Tackaberry wrote: > if (glue || !strcmp(tc->repo_id, "")) What exactly are repo_id and repo_object? Can't seem to follow this bit of the code. Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |
From: Jason T. <ta...@li...> - 2001-01-26 15:05:41
|
> > if (glue || !strcmp(tc->repo_id, "")) > > What exactly are repo_id and repo_object? Can't seem to follow this bit of > the code. repo_id is the repository id of the interface (or struct, or union, or enum, etc.) of the type. For example, IDL:Module/Interface:1.0. The snippet of code above checks to see if we know about the interface described by the repo_id (it looks it up in the hash table), or if the repo_id is an empty string, which means that the type is an generic object reference. I'm really not sure why ORBit uses an empty repo id and not IDL:CORBA/Object. Jason. |
From: Christian R. R. <ki...@as...> - 2001-01-26 16:55:15
|
On Fri, 26 Jan 2001, Jason Tackaberry wrote: > > > if (glue || !strcmp(tc->repo_id, "")) > > > > What exactly are repo_id and repo_object? Can't seem to follow this bit of > > the code. > > repo_id is the repository id of the interface (or struct, or union, or > enum, etc.) of the type. For example, IDL:Module/Interface:1.0. > > The snippet of code above checks to see if we know about the interface > described by the repo_id (it looks it up in the hash table), or if the > repo_id is an empty string, which means that the type is an generic > object reference. I'm really not sure why ORBit uses an empty repo id > and not IDL:CORBA/Object. Eliott, anyone..? cares to comment as to why we're using "" for repository id for CORBA/Object types? Or is something getting lost along the way? Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |
From: Christian R. R. <ki...@as...> - 2001-01-25 22:49:39
|
On Tue, 23 Jan 2001, Jason Tackaberry wrote: > if (glue || !strcmp(tc->repo_id, "")) Fix worked - at least the object reference gets passed on. I recompiled without ORBIT_PYTHON_NOT_THREADED and of course, when I called a method that was part of an object I was passing as a parameter, I got the dreaded Fatal Python error: PyThreadState_Get: no current thread error. Recompiling with -DORBIT_PYTHON_NOT_THREADED worked fine. Thanks. Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 |