// Build instructions // g++ -g -I/path/to/boost/ -lpthread -lrt shm.cpp // // Before running, run the following command to ensure the system has no available shared memory: // [elemental@jsaxton-dev boost_1_5_9]$ dd if=/dev/zero of=/dev/shm/fill // dd: writing to `/dev/shm/fill': No space left on device // 16248681+0 records in // 16248680+0 records out // 8319324160 bytes (8.3 GB) copied, 10.8006 s, 770 MB/s // // This should crash with boost v1.59 with the following stack trace: // (gdb) where // #0 0x0000000000402186 in boost::interprocess::ipcdetail::atomic_cas32 (mem=0x7ffff7ee3000, with=1, cmp=0) at /home/elemental/boost_1_5_9/boost_1_59_0/boost/interprocess/detail/atomic.hpp:141 // #1 0x000000000040389c in boost::interprocess::ipcdetail::managed_open_or_create_impl::priv_open_or_create, 0ul>, boost::interprocess::iset_index, 16ul> > > (this= // 0x7fffffffe0f8, type=boost::interprocess::ipcdetail::DoCreate, id=@0x7fffffffe090, size=1048576, mode=boost::interprocess::read_write, addr=0x0, perm=..., construct_func=...) // at /home/elemental/boost_1_5_9/boost_1_59_0/boost/interprocess/detail/managed_open_or_create_impl.hpp:409 // #2 0x0000000000403163 in boost::interprocess::ipcdetail::managed_open_or_create_impl::managed_open_or_create_impl, 0ul>, boost::interprocess::iset_index, 16ul> > > // (this=0x7fffffffe0f8, id=@0x7fffffffe090, size=1048576, mode=boost::interprocess::read_write, addr=0x0, construct_func=..., perm=...) // at /home/elemental/boost_1_5_9/boost_1_59_0/boost/interprocess/detail/managed_open_or_create_impl.hpp:184 // #3 0x0000000000402f2b in boost::interprocess::basic_managed_shared_memory, 0ul>, boost::interprocess::iset_index>::basic_managed_shared_memory (this=0x7fffffffe0f0, name=0x4077fb "foobar", size=1048576, addr=0x0, perm=...) at /home/elemental/boost_1_5_9/boost_1_59_0/boost/interprocess/managed_shared_memory.hpp:106 // #4 0x00000000004016a2 in main (argc=1, argv=0x7fffffffe228) at shm.cpp:23 // // Note: Before running the program, run "rm /dev/shm/foobar; dd if=/dev/zero of=/dev/shm/fill2" to ensure the system has no available shared memory. #include #include int main(int argc, char** argv) { namespace bi = boost::interprocess; bi::managed_shared_memory segment(bi::create_only, "foobar", 1 * 1024 * 1024); std::cout << "Success" << std::endl; }