-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in lock-free sofi #2160
Comments
@elfenpiff This also assumes that there are multiple pushers. SOFI was designed for SPSC. All we said way that by accident is could also be SPMC, but we never had MPMC in mind |
Yes, this is not an issue for iceoryx1 since there is a Mutex in the I would not complicate the code just catch a misuse. |
Well, there is one valid use case and we need to decide whether we want to support it. If one could guarantee that no concurrent pushes happen but still multiple producer threads access the SOFI, e.g. by exchanging an access token via a relaxes atomic, the synchronization of |
@elfenpiff @budrus do you agree to close this issue. From my point of view this is not a bug since the SpscSofi is, as the name suggests, a single producer single consumer queue. If used in a multi pusher context, it needs to be guarded with a mutex (or different synchronization mechanism), like it is done in the |
Required information
Assume the following scenario: A new subscriber subscribes to a service with a history size of
N
. The subscriber's buffer has a capacity ofN
as well, and the history is full.SoFi::push
until sofi is full and the next push call would cause an overflow. The memory is correctly synced withm_write_pos.store(std::memory_order_release)
m_write_pos.load(std::memory_order_acquire)
call to sync them_data
memory from the roudi thread to the publisher thread. The publisher may return an unsynced garbage value.See:
iceoryx/iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_sofi.inl
Line 143 in 2c612f5
So, whenever the
push
method in sofi is called from multiple threads non-concurrently, those threads must syncm_data
for the overflow case.The text was updated successfully, but these errors were encountered: