diff --git a/boost/interprocess/detail/managed_open_or_create_impl.hpp b/boost/interprocess/detail/managed_open_or_create_impl.hpp index 84a89ad919..f39683f875 100644 --- a/boost/interprocess/detail/managed_open_or_create_impl.hpp +++ b/boost/interprocess/detail/managed_open_or_create_impl.hpp @@ -310,7 +310,7 @@ class managed_open_or_create_impl //File existing when trying to create, but non-existing when //trying to open, and tried MaxCreateOrOpenTries times. Something fishy //is happening here and we can't solve it - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_create_else_open: file exists when trying to create, but not when trying to open"); } else{ BOOST_TRY{ @@ -367,7 +367,7 @@ class managed_open_or_create_impl } else{ atomic_write32(patomic_word, CorruptedSegment); - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_map_after_create: corrupted segment"); } } BOOST_CATCH(...){ @@ -401,7 +401,7 @@ class managed_open_or_create_impl while(1){ if(!get_file_size(file_handle_from_mapping_handle(dev.get_mapping_handle()), filesize)){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "do_map_after_open: get_file_size failed"); } if (filesize != 0) break; @@ -410,14 +410,14 @@ class managed_open_or_create_impl //to minimally increase the size of the file: something bad has happened const usduration elapsed(microsec_clock::universal_time() - ustime_start); if (elapsed > TimeoutSec){ - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_map_after_open: too much elapsed time in get_file_size"); } swait.yield(); } } //The creator detected an error creating the file and signalled it with size 1 if(filesize == 1){ - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_map_after_open: creating of file failed"); } } @@ -431,13 +431,13 @@ class managed_open_or_create_impl spin_wait swait; while ((value = atomic_read32(patomic_word)) != InitializedSegment){ if(value == CorruptedSegment){ - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_map_after_open: corrupted segment"); } //More than MaxZeroTruncateTimeSec seconds waiting to the creator //to minimally increase the size of the file: something bad has happened const usduration elapsed(microsec_clock::universal_time() - ustime_start); if (elapsed > TimeoutSec){ - throw interprocess_exception(error_info(corrupted_error)); + throw interprocess_exception(error_info(corrupted_error), "do_map_after_open: too much time elapsed in reading patomic_word"); } swait.yield(); } @@ -470,11 +470,11 @@ class managed_open_or_create_impl const std::size_t func_min_size = construct_func.get_min_size(); if( (std::size_t(-1) - ManagedOpenOrCreateUserOffset) < func_min_size || size < (func_min_size + ManagedOpenOrCreateUserOffset) ){ - throw interprocess_exception(error_info(size_error)); + throw interprocess_exception(error_info(size_error), "priv_open_or_create: insufficient size"); } //Check size can be represented by offset_t (used by truncate) if (!check_offset_t_size(size, file_like_t())){ - throw interprocess_exception(error_info(size_error)); + throw interprocess_exception(error_info(size_error),"priv_open_or_create: size does not fit as offset_t"); } } diff --git a/boost/interprocess/detail/shared_dir_helpers.hpp b/boost/interprocess/detail/shared_dir_helpers.hpp index 8d9d36f2db..6c2cc2e69c 100644 --- a/boost/interprocess/detail/shared_dir_helpers.hpp +++ b/boost/interprocess/detail/shared_dir_helpers.hpp @@ -68,7 +68,7 @@ struct shared_dir_constants //Throw if bootstamp not available if(!winapi::get_last_bootup_time(stamp)){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "windows_bootstamp: winapi::get_last_bootup_time failed"); } } //Use std::string. Even if this will be constructed in shared memory, all @@ -139,7 +139,7 @@ inline void get_shared_dir_root(std::basic_string &dir_path) //We always need this path, so throw on error if(dir_path.empty()){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "get_shared_dir_root: empty dir_path"); } dir_path += shared_dir_constants::dir_interprocess(); @@ -211,7 +211,7 @@ inline void create_shared_dir_and_clean_old(std::basic_string &shared_dir //If fails, check that it's because already exists if(!open_or_create_shared_directory(root_shared_dir.c_str())){ error_info info(system_error_code()); - throw interprocess_exception(info); + throw interprocess_exception(info, "create_shared_dir_and_clean_old: open_or_create_shared_directory failed"); } #if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME) @@ -220,7 +220,7 @@ inline void create_shared_dir_and_clean_old(std::basic_string &shared_dir //If fails, check that it's because already exists if(!open_or_create_shared_directory(shared_dir.c_str())){ error_info info(system_error_code()); - throw interprocess_exception(info); + throw interprocess_exception(info, "open_or_create_shared_directory: open_or_create_shared_directory"); } //Now erase all old directories created in the previous boot sessions std::basic_string subdir = shared_dir; diff --git a/boost/interprocess/exceptions.hpp b/boost/interprocess/exceptions.hpp index 3eeb9f6e0b..cb568edc8c 100644 --- a/boost/interprocess/exceptions.hpp +++ b/boost/interprocess/exceptions.hpp @@ -43,7 +43,7 @@ class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception BOOST_CATCH(...) {} BOOST_CATCH_END } - interprocess_exception(const error_info &err_info, const char *str = 0) + interprocess_exception(const error_info &err_info, const char *str /*= 0*/) : m_err(err_info) { BOOST_TRY{ @@ -83,7 +83,7 @@ class BOOST_SYMBOL_VISIBLE lock_exception : public interprocess_exception { public: lock_exception(error_code_t err = lock_error) BOOST_NOEXCEPT - : interprocess_exception(err) + : interprocess_exception(err, "lock_exception") {} const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE diff --git a/boost/interprocess/mapped_region.hpp b/boost/interprocess/mapped_region.hpp index 1ef284522f..8badff699a 100644 --- a/boost/interprocess/mapped_region.hpp +++ b/boost/interprocess/mapped_region.hpp @@ -350,7 +350,7 @@ inline void mapped_region::priv_size_from_mapping_size boost::uintmax_t(mapping_size - (offset - page_offset)) > boost::uintmax_t(std::size_t(-1))){ error_info err(size_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::priv_size_from_mapping_size failed"); } size = static_cast(mapping_size - offset); } @@ -426,7 +426,7 @@ inline mapped_region::mapped_region default: { error_info err(mode_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr unknown mode"); } break; } @@ -446,7 +446,7 @@ inline mapped_region::mapped_region //Check if all is correct if(!native_mapping_handle){ error_info err ((int)winapi::get_last_error()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr winapi::create_file_mapping failed"); } handle_to_close = native_mapping_handle; } @@ -466,7 +466,7 @@ inline mapped_region::mapped_region offset_t mapping_size; if(!winapi::get_file_mapping_size(native_mapping_handle, mapping_size)){ error_info err((int)winapi::get_last_error()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: get_file_mapping_size failed"); } //This can throw priv_size_from_mapping_size(mapping_size, offset, page_offset, size); @@ -482,7 +482,7 @@ inline mapped_region::mapped_region //Check error if(!base){ error_info err((int)winapi::get_last_error()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: winapi::map_view_of_file_ex failed"); } //Calculate new base for the user @@ -497,7 +497,7 @@ inline mapped_region::mapped_region if(!winapi::duplicate_current_process_handle(mhandle.handle, &m_file_or_mapping_hnd)){ error_info err((int)winapi::get_last_error()); this->priv_close(); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: winapi::duplicate_current_process_handle failed"); } } @@ -600,7 +600,7 @@ inline mapped_region::mapped_region int ret = ::shmctl(map_hnd.handle, IPC_STAT, &xsi_ds); if(ret == -1){ error_info err(system_error_code()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: shmctl failed"); } //Compare sizess if(size == 0){ @@ -608,7 +608,7 @@ inline mapped_region::mapped_region } else if(size != (std::size_t)xsi_ds.shm_segsz){ error_info err(size_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: size not xsi_ds.shm_segsz"); } //Calculate flag int flag = map_options == default_map_options ? 0 : map_options; @@ -617,7 +617,7 @@ inline mapped_region::mapped_region } else if(m_mode != read_write){ error_info err(mode_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: unknown mode"); } //Attach memory //Some old shmat implementation take the address as a non-const void pointer @@ -626,7 +626,7 @@ inline mapped_region::mapped_region void *base = ::shmat(map_hnd.handle, final_address, flag); if(base == (void*)-1){ error_info err(system_error_code()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: shmat failed"); } //Update members m_base = base; @@ -645,7 +645,7 @@ inline mapped_region::mapped_region struct ::stat buf; if(0 != fstat(map_hnd.handle, &buf)){ error_info err(system_error_code()); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: fstat == 0"); } //This can throw priv_size_from_mapping_size(buf.st_size, offset, page_offset, size); @@ -688,7 +688,7 @@ inline mapped_region::mapped_region default: { error_info err(mode_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: unknown mode"); } break; } @@ -704,7 +704,7 @@ inline mapped_region::mapped_region //Check if mapping was successful if(base == MAP_FAILED){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: mmap failed"); } //Calculate new base for the user @@ -716,7 +716,7 @@ inline mapped_region::mapped_region if(address && (base != address)){ error_info err(busy_error); this->priv_close(); - throw interprocess_exception(err); + throw interprocess_exception(err, "mapped_region::ctr: fixed mapping error"); } } diff --git a/boost/interprocess/segment_manager.hpp b/boost/interprocess/segment_manager.hpp index 983b0f15d6..e0b3338c60 100644 --- a/boost/interprocess/segment_manager.hpp +++ b/boost/interprocess/segment_manager.hpp @@ -1128,7 +1128,7 @@ class segment_manager return it->get_block_header()->value(); } if(dothrow){ - throw interprocess_exception(already_exists_error); + throw interprocess_exception(already_exists_error,"priv_generic_named_construct: dowthrow == true"); } else{ return 0; diff --git a/boost/interprocess/shared_memory_object.hpp b/boost/interprocess/shared_memory_object.hpp index 2d429efcb1..cfdcc7cc41 100644 --- a/boost/interprocess/shared_memory_object.hpp +++ b/boost/interprocess/shared_memory_object.hpp @@ -234,7 +234,7 @@ inline bool shared_memory_object::priv_open_or_create //Set accesses if (mode != read_write && mode != read_only){ error_info err = other_error; - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create shared dir failure"); } switch(type){ @@ -250,7 +250,7 @@ inline bool shared_memory_object::priv_open_or_create default: { error_info err = other_error; - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create unknown type"); } } @@ -258,7 +258,7 @@ inline bool shared_memory_object::priv_open_or_create if(m_handle == ipcdetail::invalid_file()){ error_info err = system_error_code(); this->priv_close(); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create invalid_file"); } m_mode = mode; @@ -299,7 +299,7 @@ inline void shared_memory_object::truncate(offset_t length) { if(!ipcdetail::truncate_file(m_handle, (std::size_t)length)){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::truncate"); } } @@ -366,7 +366,7 @@ inline bool shared_memory_object::priv_open_or_create } else{ error_info err(mode_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create unknown mode"); } ::mode_t unix_perm = perm.get_permissions(); @@ -414,7 +414,7 @@ inline bool shared_memory_object::priv_open_or_create default: { error_info err = other_error; - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create type unknown"); } } @@ -422,7 +422,7 @@ inline bool shared_memory_object::priv_open_or_create if(m_handle < 0){ error_info err = errno; this->priv_close(); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::priv_open_or_create shm_open failed"); } m_filename = filename; @@ -464,7 +464,7 @@ inline void shared_memory_object::truncate(offset_t length) if (ret && ret != EOPNOTSUPP && ret != ENODEV){ error_info err(ret); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::truncate posix failure"); } //ftruncate fallback #endif //BOOST_INTERPROCESS_POSIX_FALLOCATE @@ -474,7 +474,7 @@ inline void shared_memory_object::truncate(offset_t length) if (errno == EINTR) goto handle_eintr; error_info err(system_error_code()); - throw interprocess_exception(err); + throw interprocess_exception(err, "shared_memory_object::truncate failure"); } } diff --git a/boost/interprocess/sync/posix/condition.hpp b/boost/interprocess/sync/posix/condition.hpp index f151a5b98c..09b6bc3c03 100644 --- a/boost/interprocess/sync/posix/condition.hpp +++ b/boost/interprocess/sync/posix/condition.hpp @@ -158,12 +158,12 @@ inline posix_condition::posix_condition() res = pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED); if(res != 0){ pthread_condattr_destroy(&cond_attr); - throw interprocess_exception(res); + throw interprocess_exception(res,"posix_condition::ctr pthread_condattr_setpshared failed"); } res = pthread_cond_init(&m_condition, &cond_attr); pthread_condattr_destroy(&cond_attr); if(res != 0){ - throw interprocess_exception(res); + throw interprocess_exception(res, "posix_condition::ctr pthread_cond_init failed"); } } diff --git a/boost/interprocess/sync/posix/semaphore_wrapper.hpp b/boost/interprocess/sync/posix/semaphore_wrapper.hpp index 77ba486312..173751c8a1 100644 --- a/boost/interprocess/sync/posix/semaphore_wrapper.hpp +++ b/boost/interprocess/sync/posix/semaphore_wrapper.hpp @@ -100,13 +100,13 @@ inline bool semaphore_open default: { error_info err(other_error); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_open: unknown type"); } } //Check for error if(handle == BOOST_INTERPROCESS_POSIX_SEM_FAILED){ - throw interprocess_exception(error_info(errno)); + throw interprocess_exception(error_info(errno),"semaphore_open: sem_open failed"); } return true; @@ -148,7 +148,7 @@ inline void semaphore_init(sem_t *handle, unsigned int initialCount) //In the future, a successful call might be required to return 0. if(ret == -1){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_init: sem_init failed"); } } @@ -167,7 +167,7 @@ inline void semaphore_post(sem_t *handle) int ret = sem_post(handle); if(ret != 0){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_post: sem_post failed"); } } @@ -176,7 +176,7 @@ inline void semaphore_wait(sem_t *handle) int ret = sem_wait(handle); if(ret != 0){ error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_wait: sem_wait failed"); } } @@ -189,7 +189,7 @@ inline bool semaphore_try_wait(sem_t *handle) return false; } error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_try_wait: sem_trywait failed"); } #ifndef BOOST_INTERPROCESS_POSIX_TIMEOUTS @@ -235,7 +235,7 @@ inline bool semaphore_timed_wait(sem_t *handle, const TimePoint &abs_time) return false; } error_info err = system_error_code(); - throw interprocess_exception(err); + throw interprocess_exception(err, "semaphore_timed_wait: sem_timedwait failed"); } return false; #else //#ifdef BOOST_INTERPROCESS_POSIX_TIMEOUTS