Problems marshalling an any
- From: "Verwerft, Marc" <MVerwerft nedcar nl>
- To: "'orbit-list gnome org'" <orbit-list gnome org>
- Subject: Problems marshalling an any
- Date: Tue, 3 Oct 2000 16:52:49 +0200
Hi,
I'm currently testing a client (in ORBit 0-5-3 stable but ported to VMS,
using C bindings) program that attaches to an eventchannel as a
pushsupplier. Everything seems to work, I get the channel from an ior,
invoke the for_suppliers() and obtain_push_consumer() methods. Things break
when I try to send something (any-thing ;-) ) and it appears to go wrong in
the ORBit_marshal_any() call. I invariably get an access violation (VMS
terms for telling me that I'm reading/writing outside of my memory space)
code snippet from my program:
...
any = CORBA_any_alloc();
any->_value = (char *) malloc(20);
any->_type = TC_string;
for (i=0; i< 5; i++) {
sprintf(any->_value, "Attempt %d", i);
CosEventChannelAdmin_ProxyPushConsumer_push(proxy_push_con, any, &ev);
Exception(&ev);
}
1. Is there anything wrong with this code ? I haven't found an example where
the any is used as a 'stringholder', so I just guessed. Any pointers would
be appreciated.
2. In the code of ORBit_marshal_any() the _value field of the any param is
assigned to an gpointer 'mval' (see following snippet). Then
ORBit_marshal_value is called using the address of mval, handing over a void
**, right ? However, in the section of ORBit_marshal_value that deals with
strings, I think there is something wrong.
ulval = strlen(*(char **)*val) + 1;
Why is *val cast to a char ** ? Shouldn't it be :
ulval = strlen(*(char **)val) + 1; ?
3. Is there anything else I missed ?
By the way, this is the first program that fails and I already tested a
couple of other programs using the same setup (ORBit on VMS as client,
Javaorb on VMS as server) and they work great together. This is the first
test that involves an 'any'.
Thanks for any help in advance.
Marc Verwerft.
code snippet from corba_any.c :
void
ORBit_marshal_any(GIOPSendBuffer *buf, const CORBA_any *val)
{
ORBit_marshal_value_info mi;
gpointer mval = val->_value;
ORBit_encode_CORBA_TypeCode(val->_type, buf);
ORBit_marshal_value(buf, &mval, val->_type, &mi);
}
static void
ORBit_marshal_value(GIOPSendBuffer *buf,
gpointer *val,
CORBA_TypeCode tc,
ORBit_marshal_value_info *mi)
{
CORBA_unsigned_long i, ulval;
gpointer subval;
ORBit_marshal_value_info submi;
...
case CORBA_tk_string:
ulval = strlen(*(char **)*val) + 1;
/* SEE HERE !!!!!*/
*val = ALIGN_ADDRESS(*val, ALIGNOF_CORBA_POINTER);
giop_send_buffer_append_mem_indirect_a(buf,
&ulval,
sizeof(CORBA_unsigned_long));
giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER(buf), *(char
**)*val, ulval);
*val = ((guchar *)*val) + sizeof(char *);
break;
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]