iceoryx icon indicating copy to clipboard operation
iceoryx copied to clipboard

Verify that `PointerRepository` does not have to be thread-safe

Open elfenpiff opened this issue 1 year ago • 9 comments

Brief feature description

In a this discussion it was unraveled that the PointerRepository is not-thread-safe: https://github.com/eclipse-iceoryx/iceoryx/pull/1699#discussion_r984338244

@elBoberido drafted the following possible scenario:

  • thread A is started
  • thread B is started
  • thread A registers a pointer
  • thread B registers a pointer -> is this a valid use case
  • thread B uses a relative pointer -> do we need to sync the memory

Do we require memory synchronizations here or even place some kind of thread-safe mechanism? This has to be investigated further.

In my opinion the drafted scenario is a valid use case but I think that iceoryx does not use the pointer repository in that fashion. A startup looks like:

  • runtime registers at roudi
  • roudi sends a list with all shared memory segments to the application
  • one thread in the application receive this list and registers all segments in the pointer repository
  • since the runtime init is the first call threads will start to pop up after the registration is finalized

Furthermore, the pointer repository is an internal construct. So I think that we currently do not have a bug but since the expected behavior differs from the actual one we require a solution for the scenario drafted by @elBoberido . Which includes

  • threadsafe pointer registration
  • sync between threads

Or we try to avoid this by defining a strict contract. The problem is unregister, what happens when a thread unregisters a segment while others are still using them (or the relative pointers on them).

elfenpiff avatar Sep 30 '22 11:09 elfenpiff