Archived

This topic is now archived and is closed to further replies.

Handling pointer addresses

This topic is 5774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have 2 processes talking to each other. Process A allocates objects and sends the addresses of these objects to process B. Process B sends the address of an object to process A which invokes methods on this object. BUT sometimes, the addresses turn out to be invalid causing a coredump. How best can I handle this ?

Share this post


Link to post
Share on other sites
You can''t do this, as the OS is free to do whatever it likes to cause these addresses to become invalid, as you are discovering. An address is generally only guaranteed to remain valid within a single process space. If you wish to communicate across processes, you must get the OS to act as an intermediary between them. That''s what technologies such as shared memory, RPC, DCOM, etc, are for. You didn''t state exactly what you are doing, but I''m surprised it works at all.

--
1st law of programming: Any given program, when running, is obsolete.

Share this post


Link to post
Share on other sites
If you''re using *NIX, have a look at mmap().
A quick lookup in MSDN gave me the CSharedFile class.
Further searching gave CreateSharedMemory(), AllocateSharedMemory() and FreeSharedMemory(), as well as VirtualAlloc() and VirtualAllocEx()

Share this post


Link to post
Share on other sites