interprocess icon indicating copy to clipboard operation
interprocess copied to clipboard

boost interprocess spin wait deadlock when process crash in shared memory alloc

Open 363568233 opened this issue 7 years ago • 1 comments

void yield() { //Lazy initialization of limits if( !m_k){ this->init_limits(); } //Nop tries if( m_k < (nop_pause_limit >> 2) ){

  }
  //Pause tries if the processor supports it
  #if defined(BOOST_INTERPROCESS_SMT_PAUSE)
  else if( m_k < nop_pause_limit ){
     BOOST_INTERPROCESS_SMT_PAUSE
  }
  #endif
  //Yield/Sleep strategy
  else{
     //Lazy initialization of tick information
     if(m_k == nop_pause_limit){
        this->init_tick_info();
     }
     else if( this->yield_or_sleep() ){
        ipcdetail::thread_yield();
     }
     else{
        ipcdetail::thread_sleep_tick();
     }
  }
  ++m_k;

}

363568233 avatar Dec 04 '18 10:12 363568233

I used try_atomic_func() which gets segment_manager as its parameter. The function will return false in case of segment is locked. BUT concurrency issues might happen in some cases (e.g when a thread is allocating while another thread is trying to find the allocated memory.

**Edited: BUT I'm looking forward to find a better solution

rezaebrh avatar May 29 '19 07:05 rezaebrh