Pointer problem

Hi,
first of all, the code:

RPC<uint32> local_catalog_address = remote_qp.get_local_catalog();

cout << "local_catalog_address: " << local_catalog_address << endl;

Diagram *catalog;
catalog = (Diagram*) (*local_catalog_address);

cout << "catalog address: " << &catalog << endl;
cout << "catalog is pointing to " << catalog << endl;

cout << catalog->as_string();

local_catalog_address if the momery location of a Diagram object.
When I print "catalog is point to ..." the address is the correct address (&(0x8b4fbe8) for example). I'm sure that the address is correct because I print it on the class containing the method get_local_catalog(), and the addresses match.
I have a segmentation fault when I try to invoke the method as_string(), even if this method is working when used on the other class.
Am I missing something???

Thanks in advance
Typecasts are almost always suspicious.

1
2
RPC<uint32> local_catalog_address = remote_qp.get_local_catalog();
Diagram *catalog = (Diagram*) (*local_catalog_address);


You aren't using RPC to pass around pointers, are you? A pointer that is valid in one process' address space is not valid in another's.

The method get_local_catalog() does this:

RPC< uint32 > get_local_catalog()
{
NOTICE << &_local_catalog;
return(uint32(&_local_catalog));
};

So it returns the uint32 (long unsigned int) of the memory location of his Diagram object
Do you have any ideas about how can use this value?
I cannot change this method...

Thanks in advance
Casting from uint32 to a pointer to a Diagram to me is very suspicious.

Is this part of a remote procedure call? That is, is this uint32 value coming from another process? If so, it is totally wrong, in that you can't pass a pointer to an object from one process' address space to another process and expect the recipient to be able to access the object. This is what CORBA and the like are for.
Ok, I understand

Thanks so much, i will try in another way
Topic archived. No new replies allowed.