to-do.txt 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. Remove std::iterator_traits and use pointer_traits
  11. What values should take shared memory allocators:
  12. propagate_on_container_copy_assignment
  13. propagate_on_container_move_assignment
  14. propagate_on_container_swap
  15. //////////////////////////////////////////////////////////////////////////////
  16. Platform conformance
  17. //////////////////////////////////////////////////////////////////////////////
  18. //////////
  19. FreeBSD
  20. //////////
  21. Tested until FreeBSD 9
  22. Shared memory: FreeBSD < 7 filesystem semantics
  23. HISTORY
  24. The shm_open() and shm_unlink() functions first appeared in FreeBSD 4.3.
  25. The functions were reimplemented as system calls using shared memory
  26. objects directly rather than files in FreeBSD 7.0.
  27. BUG: MAP_PRIVATE requires read-write access to shared memory object (mapped files work fine)
  28. Named semaphore: _POSIX_SEMAPHORES not defined. Limited named semaphore support (short names)
  29. Process shared: _POSIX_THREAD_PROCESS_SHARED not defined
  30. //////////
  31. Linux 2.6
  32. //////////
  33. All Fine
  34. -> add contiguous_elements option to burst allocation
  35. -> Test construct<> with throwing constructors
  36. -> Implement zero_memory flag for allocation_command
  37. -> The general allocation funtion can be improved with some fixed size allocation bins.
  38. -> Adapt error reporting to TR1 system exceptions
  39. -> Improve exception messages
  40. -> Movability of containers should depend on the no-throw guarantee of allocators copy constructor
  41. -> Check self-assignment for vectors
  42. -> Update writing a new memory allocator explaining new functions (like alignment)
  43. -> private node allocators could take the number of nodes as a runtime parameter.
  44. -> Explain how to build intrusive indexes.
  45. -> Add intrusive index types as available indexes.
  46. -> Add maximum alignment allocation limit in PageSize bytes. Otherwise, we can't
  47. guarantee alignment for process-shared allocations.
  48. -> Add default algorithm and index types. The user does not need to know how are
  49. they implemented.
  50. -> Pass max size check in allocation to node pools
  51. -> Use in-place expansion capabilities to shrink_to_fit and reserve functions
  52. from iunordered_index.
  53. -> change unique_ptr to avoid using compressed_pair
  54. -> Improve unique_ptr test to test move assignment and other goodies like assigment from null
  55. -> barrier_test fails on MacOS X on PowerPC.
  56. -> use virtual functions to minimize template explosion in managed classes
  57. -> Insertions with InpIt are not tested in containers
  58. -> Run tests with rvalue reference compilers with no variadic insertions
  59. -> find a way to pass security attributes to shared memory
  60. -> Implement vector with memcpy/memmove for trivially copyable types.
  61. -> flat_xxx constructors are not documented
  62. -> operator >> and similar need moved_value
  63. -> rvalue reference enabled compilers are not optimized with has_move_emulation_enabled and move_iterator
  64. -> Add allocator test template that test all new functions (allocate_many, etc.)
  65. -> MacOS shm_open is non-conformant. Is there a way to know the size of a shared memory object?
  66. -> swap() of multiallocaiton iterator is wrong. Try to reimplement it with slist
  67. -> Could the mapped_file constructor allow a wchar_t filename on Windows?
  68. Or some cross-platform way to get Unicode support?
  69. -> map::node_ptr p = m.create_node(my_special_cheap_key_value, mv1, mv2);
  70. //We would need to unconst-cast...
  71. const_cast<Key&>(p->first) = modify( p->second );
  72. m.insert( boost::move(p) );
  73. -> I found some bug in the interprocess library. I use
  74. boost::interprocess::managed_mapped_file class and
  75. managed_mapped_file::shrink_to_fit() method to decrease the size of file
  76. on the disk. It works good but the thread hang up on shrink_to_fit() call
  77. if the file exists already and it's size is zero. It makes me check the
  78. file existance and it's size before shrink_to_fit() call.
  79. Thank you!
  80. -> Ticket URL: <https://svn.boost.org/trac/boost/ticket/3375>
  81. ->Robust mutex emulation:
  82. Two new fields:
  83. - owner
  84. - state
  85. Use intermodule singleton to store the lock file name
  86. LOCK
  87. if (broken_id){
  88. throw exception;
  89. }
  90. lock_own_unique_file();
  91. while(1){
  92. if (try_lock_mtx){
  93. write unique_id
  94. }
  95. else{
  96. sleep();
  97. ++tries;
  98. if(tries > 100)
  99. if(!robust_check()){
  100. tries = 0;
  101. }
  102. else{
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. UNLOCK
  109. if (fixing_mode){
  110. write_broken_id
  111. }
  112. else{
  113. write invalid_id
  114. }
  115. unlock_mtx
  116. ROBUST_CHECK
  117. if(check_if_owner_dead_and_take_ownership_atomically()){
  118. return false;
  119. }
  120. write fixing_id
  121. CHECK_IF_OWNER_DEAD_AND_TAKE_OWNERSHIP_ATOMICALLY
  122. do{
  123. old_owner = read_owner_atomically()
  124. if(check_owner_unique_resource_is_dead(old_owner){
  125. return true;
  126. }
  127. }while(cas(old_owner, cur_owner) == old_owner);
  128. return false;
  129. CHECK_OWNER_UNIQUE_RESOURCE_IS_DEAD(owner)
  130. file = file_to_owner(owner);
  131. if(file_exists(file)){
  132. if(try_lock(file)){
  133. write_owner_atomically();
  134. remove(file);
  135. unlock(file)
  136. return true;
  137. }
  138. }
  139. return false;
  140. LOCK_OWN_UNIQUE_FILE
  141. class MyRobustMutexLockFile
  142. {
  143. int fd;
  144. };
  145. MyRobustMutexLockFile()
  146. {
  147. //loop create_and_lock because another process
  148. //can lock and erase it
  149. //better create, lock and rename?
  150. fd = create_file(lockfilename);
  151. while(1){
  152. lock_file(fd);
  153. int fd2 = create_exclusive(lockfilename);
  154. if(fd2){
  155. close(fd);
  156. fd = fd2;
  157. continue;
  158. }
  159. else if(already_exist_error){ //must already exist
  160. break;
  161. }
  162. else{
  163. close(fd);
  164. throw exception;
  165. }
  166. }
  167. }
  168. ~MyRobustMutexLockFile()
  169. {
  170. close(fd);
  171. //No race condition because
  172. //if any other thread tries to create the file
  173. //the shm has a lock so constructor/destructor is serialized
  174. unlink(lockfilename)
  175. }
  176. ipcdetail::intermodule_singleton<MyRobustMutexLockFile>::get();
  177. Add unsigned overflow checking with shortcut as explained here:
  178. https://github.com/ivmai/bdwgc/commit/83231d0ab5ed60015797c3d1ad9056295ac3b2bb
  179. # define GC_SIZE_MAX (~(size_t)0)
  180. #endif
  181. +#define GC_SQRT_SIZE_MAX ((1U << (WORDSZ / 2)) - 1)
  182. +
  183. void * calloc(size_t n, size_t lb)
  184. {
  185. - if (lb && n > GC_SIZE_MAX / lb)
  186. + if ((lb | n) > GC_SQRT_SIZE_MAX /* fast initial test */
  187. + && lb && n > GC_SIZE_MAX / lb)
  188. return NULL;