cameron314 / concurrentqueue

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11
Other
9.87k stars 1.69k forks source link

bus error occurs when program runs to line at "index &= hash->capacity - 1u;" in file concurrentqueue.h #337

Closed JiangDonglai98 closed 1 year ago

JiangDonglai98 commented 1 year ago

I am using the ConcurrentQueue in a condition for multi-producers and one consumer in different threads. Those producers' threads has their own locks, and consumer no lock. Can I use this ConcurrentQueue in this acondition? After I finish build and running the code, it first get an segmentation fault. I go through the printout and locate the problem to that line of code "index &= hash->capacity - 1u;" in file concurrentqueue.h.

JiangDonglai98 commented 1 year ago

I try the demo example of multi-producers and one consumer in different threads with or without locks. It works fine. So I am not sure what cause this error.

cameron314 commented 1 year ago

Would need to see the code, but nothing sounds inherently wrong with such a setup. Please continue to try to reproduce in a self-contained example.

JiangDonglai98 commented 1 year ago

I use this queue in a singleton and open a thread to receive data structure in the singleton. Other producer threads are opened by somwhere else. I use the concurrentqueue's enqueue methos in their thread to send data structure.

image image image