1 | /*
|
---|
2 |
|
---|
3 | richardm@lukd02[dev-lon]$ g++ --version
|
---|
4 | g++ (GCC) 4.3.2
|
---|
5 | Copyright (C) 2008 Free Software Foundation, Inc.
|
---|
6 | This is free software; see the source for copying conditions. There is NO
|
---|
7 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
8 |
|
---|
9 | richardm@lukd02[dev-lon]$ uname -a
|
---|
10 | Linux lukd02 2.6.18-92.el5xen #1 SMP Tue Apr 29 13:31:30 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
|
---|
11 |
|
---|
12 | THIS BUILD COMMAND WORKS OK
|
---|
13 | g++ boost-interprocess-bug-report.cpp -pthread -m64 -I/home/richardm/tools/boost/boost-1.43.0/include -O2 -L/home/richardm/tools/boost/boost-1.43.0/lib -Bstatic -lboost_thread -o d.out -Wl,-rpath /home/richardm/tools/boost/boost-1.43.0/lib
|
---|
14 |
|
---|
15 | THIS BUILD COMMAND BUILDS A EXE THAT SEGVS
|
---|
16 | g++ boost-interprocess-bug-report.cpp -DNDEBUG -pthread -m64 -I/home/richardm/tools/boost/boost-1.43.0/include -O2 -L/home/richardm/tools/boost/boost-1.43.0/lib -Bstatic -lboost_thread -o d.out -Wl,-rpath /home/richardm/tools/boost/boost-1.43.0/lib
|
---|
17 |
|
---|
18 |
|
---|
19 | my boost install is a standard 1.43.0
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | //////////////////////////////////////////////////////////////////////////////////////////////////
|
---|
25 | #include <boost/interprocess/managed_mapped_file.hpp>
|
---|
26 | #include <boost/interprocess/containers/vector.hpp>
|
---|
27 | #include <boost/interprocess/allocators/allocator.hpp>
|
---|
28 |
|
---|
29 | #include <iostream>
|
---|
30 |
|
---|
31 | // using namespace boost::interprocess;
|
---|
32 |
|
---|
33 |
|
---|
34 | typedef boost::interprocess::allocator<int, boost::interprocess::managed_mapped_file::segment_manager> MyAllocator;
|
---|
35 | typedef boost::interprocess::vector<int, MyAllocator> MyVector;
|
---|
36 |
|
---|
37 | int main(int argc, char *argv[])
|
---|
38 | {
|
---|
39 | try{
|
---|
40 | std::cout << "calling constructor.." << std::endl;
|
---|
41 | boost::interprocess::managed_mapped_file segment(boost::interprocess::open_or_create, "MyMemMapFile", 65536);
|
---|
42 | std::cout << "mapped." << std::endl;
|
---|
43 |
|
---|
44 | MyAllocator alloc_inst (segment.get_segment_manager());
|
---|
45 |
|
---|
46 | // the presence of this line causes the above managed_mapped_file constructor to segv
|
---|
47 | MyVector *myvector = segment.find_or_construct<MyVector>("MyVector")(alloc_inst);
|
---|
48 |
|
---|
49 | std::cout << "vector constructed." << std::endl;
|
---|
50 |
|
---|
51 | }
|
---|
52 | catch(std::exception & x )
|
---|
53 | {
|
---|
54 | std::cout << "exception:" << x.what() << std::endl;
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | return 0;
|
---|
59 | };
|
---|