|
Boost : |
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2008-06-15 08:37:53
Darren Garvey wrote:
> Hello Ion,
>
> Title says it all really: the attached mini-program gives me a segmentation
> fault on ubuntu linux 8.04 with gcc 4.2.3 when trying to read back the
> shared memory between process invocations (trying a similar program on XP
> also fails). If the comments on lines 33/34 and 66-67/68-69 are swapped it
> works as expected. I've also tried and failed to get it working with my own
> types as well as std::string.
>
I haven't looked closely at the types in your program, but I believe
shared memory can only be used with POD types. No types that have their
own indirection to other data structures (such as virtual tables, or
their own heap-allocated memory, such as std::string).
This is because only the object's own address is remapped into different
processes, but if they use pointers internally there are good chances
they are only correct for one process (the one allocating the object).
Regards,
Stefan
-- ...ich hab' noch einen Koffer in Berlin...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk