Opened 9 years ago
Closed 8 years ago
#9911 closed Bugs (fixed)
[Interprocess] get_tmp_base_dir(...) failure
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | interprocess |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
In Boost 1.55 get_tmp_base_dir(...) is defined as such:
inline void get_tmp_base_dir(std::string &tmp_name) { #if defined (BOOST_INTERPROCESS_WINDOWS) winapi::get_shared_documents_folder(tmp_name); if(tmp_name.empty() || !winapi::is_directory(tmp_name.c_str())){ tmp_name = get_temporary_path(); } #else tmp_name = get_temporary_path(); #endif if(tmp_name.empty()){ error_info err = system_error_code(); throw interprocess_exception(err); } //Remove final null. tmp_name += "/boost_interprocess"; }
This makes an assumption in Windows that, if the "shared documents folder" is not usable, the temp folder should be used instead. I believe this is a bad assumption, and leads to silent run-time failures.
Every user in Windows is going to have a different temp folder. Thus, processes running under different users will not agree on the same base folder for boost_interprocess. This obviously defeats the purpose of shared memory.
I believe a failure to secure a shared location in Windows for boost_interprocess should result in an exception, not a fall back to the non-shared temp folder.
PS - It would be beneficial if the location of the boost_interprocess folder could be specified. Instead of relying on registry entries, environment variables, or Windows API voodoo, I can tell the library exactly what folder to use, and save everyone some work.
Implemented the suggested workaround in commit SHA-1: fb1b0e547c8afe60cb9c1a008ce38a8606f7536d (develop branch)
If the shared folder could not be found an exception is thrown and no temporary folder is tried. If BOOST_INTERPROCESS_SHARED_DIR_PATH is defined, that directory is used instead of the shared folder + bootstamp folder.