Opened 11 years ago
Closed 11 years ago
#6054 closed Bugs (fixed)
Reading Shared Memory from x86 to x64 and vice versa on OSX
| Reported by: | Owned by: | Ion Gaztañaga | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | interprocess | 
| Version: | Boost 1.47.0 | Severity: | Showstopper | 
| Keywords: | Cc: | 
Description
If I create a SM from 64 bit application and open it on 32 bit application it fails.
for 64 bit
shared_memory_object( create_only, "test" , read_write) ;
for 32 bit
shared_memory_object (open_only, "test", read_write);
file created by 64bit application is at path as below:
/private/tmp/boost_interprocess/AD21A54E000000000000000000000000/test where as file searched by 32 bit application is at path
/private/tmp/boost_interprocess/AD21A54E00000000/test Thus 32 bit applications cannot read the file.
I am using boost 1.47.0 on Mac OS X. Is it a bug? Do I have to do some settings use some Macros in order to fix it? Has any one encountered this problem before?
This Bug is present in tmp_dir_helpers.hpp file.
       inline void get_bootstamp(std::string &s, bool add = false)
        {
          ...
           std::size_t char_counter = 0;
           long  fields[2] = { result.tv_sec, result.tv_usec };
           for(std::size_t field = 0; field != 2; ++field){
              for(std::size_t i = 0; i != sizeof(long); ++i){
                 const char *ptr = (const char *)&fields[field];
                 bootstamp_str[char_counter++] = Characters[(ptr[i]&0xF0)>>4];
                 bootstamp_str[char_counter++] = Characters[(ptr[i]&0x0F)];
              }
           ...
        }
Where as it should have been some thing like this..
   '''long long''' fields[2] = { result.tv_sec, result.tv_usec };
               for(std::size_t field = 0; field != 2; ++field){
                  for(std::size_t i = 0; i != sizeof('''long long'''); ++i)
      

Fixed in trunk. Time uses 32 bit integers on both 32 bit and 64 bit versions to avoid problems.