Re: [Orbit-python-list] (in Object obj) marshalling error
Status: Inactive
Brought to you by:
tack
|
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.
|