Dear colleagues,
I have been testing the boost interprocess library for two months in
my spare time... everything looked ok until now. Perhaps I am doing
something wrong, so be patient.
As you can see in the code, I am trying to use the offset_ptr within a
class named OffsetPtrClass. However, if I try to allocate the int
inside the OffsetPtrClass cnstructor I'll get a segmentation fault in
the getter (either the MASTER or the SLAVE forked processes).
I a running on Linux kernel 2.6.16 and g++ 3.4.xx.
What I am doing wrong?
Thanks for your help,
marc
#include <iostream>
#include
Marc Magrans de Abril wrote:
Dear colleagues,
I have been testing the boost interprocess library for two months in my spare time... everything looked ok until now. Perhaps I am doing something wrong, so be patient.
As you can see in the code, I am trying to use the offset_ptr within a class named OffsetPtrClass. However, if I try to allocate the int inside the OffsetPtrClass cnstructor I'll get a segmentation fault in the getter (either the MASTER or the SLAVE forked processes). I a running on Linux kernel 2.6.16 and g++ 3.4.xx.
What I am doing wrong?
I don't quite understand what your code is doing but first you should have created the shared memory before trying to open it. This code does not guarantee it. Another option is to create the shared memory first and fork after it. If you try to allocate the int in the master while constructing OffsetPtrClass in shared memory using a different ip::managed_shared_memory, are you sure that does not throw?
Thanks for your help, marc
I need a bit more data to help you, Ion
Dear Ion,
First of all thanks for your fast reply. I have modified the code as
suggested by you. The segmentation fault has disappeared. I do not
want to be a pest... however, Could you please explain me why there
was a segmentation fault before?
I know that the way I synchronized was not good before doing the
example. However, from the cout I supposed that the segment was
created before pressing a key (If you take a look to the code). I
neither understand why I was able to execute find<> without an
exception.
Could you please give me some more explanation?
This is the code that works...
#include <iostream>
#include
participants (2)
-
Ion Gaztañaga
-
Marc Magrans de Abril