SF-Zhou opened a new pull request #1358:
URL: https://github.com/apache/incubator-brpc/pull/1358


   This is a known bug in src/bthread/task_group_inl.h. It will cause a 
deadlock when all workers are spinning in `TaskGroup::push_rq`. A reproducible 
code:
   ```c++
   #include <bthread/bthread.h>
   
   static std::atomic<size_t> value{0};
   
   void* do_job(void*) {
     ++value;
     return nullptr;
   }
   
   void* start(void*) {
     const uint32_t M = 10000;  // bigger than default queue capacity
     std::vector<bthread_t> tids(M);
     for (auto& tid : tids) {
       bthread_start_background(&tid, &BTHREAD_ATTR_SMALL, do_job, nullptr);
     }
     for (auto& tid : tids) {
       bthread_join(tid, nullptr);
     }
     return nullptr;
   }
   
   int main(int argc, char* argv[]) {
     const uint32_t N = 10;  // bigger than default concurrency
   
     std::vector<bthread_t> tids(N);
     for (auto& tid : tids) {
       bthread_start_urgent(&tid, &BTHREAD_ATTR_SMALL, start, nullptr);
     }
     for (auto& tid : tids) {
       bthread_join(tid, nullptr);
     }
     printf("Value = %lu\n", value.load());
     return 0;
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to