Re: CORBA_any_set_release



Agnieszka Kwiecien <nova@go2.pl> wrote:
> 
> static CORBA_any *
> impl_Graph_GenSimpleGraph(impl_POA_Graph * servant,
>       Graph_SGParam * p,
>       Graph_ResType * r, CORBA_Environment * ev)
> {
>    CORBA_any *retval;
>    CORBA_boolean b = CORBA_FALSE;

This allocates b as an automatic variable on the stack.

>    retval = CORBA_any_alloc();
>    retval->_type = (CORBA_TypeCode)TC_boolean;
>    retval->_value = &b;

Now the any stores a pointer to b, which is an automatic variable on the
stack.

>    CORBA_any_set_release(retval, CORBA_TRUE);
>    return retval;

And here the stack unwinds, b is lost, and the pointer in the any becomes
invalid.

In addition, you're telling ORBit that when it frees the any, it should also
free whatever that invalid pointer happens to be pointing at.

I can tell you that what you have is wrong, but unfortunately I can't tell
you how to allocate the any or the boolean value correctly.

> I've tried to run the server on my Debian, and it worked fine. The problem
> occures when I run it on Solaris. I thought that maybe I do something not
> "exactly right" and Debian accepts it but Solaris doesn't. The server brakes
> in allocators.c while freeing some "magic" memory block.

Yes, what you're doing is wrong, but sometimes it might just work.
-- 
Sam Couter          |   Internet Engineer   |   http://www.topic.com.au/
sam@topic.com.au    |   tSA Consulting      |
OpenPGP key ID:       DE89C75C,  available on key servers
OpenPGP fingerprint:  A46B 9BB5 3148 7BEA 1F05  5BD5 8530 03AE DE89 C75C

PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]