Skip to content

Fix infinite loop in VOLATILE DataReader init_shared_segment#6343

Open
PavelGuzenfeld wants to merge 1 commit intoeProsima:masterfrom
PavelGuzenfeld:fix/volatile-reader-init-loop
Open

Fix infinite loop in VOLATILE DataReader init_shared_segment#6343
PavelGuzenfeld wants to merge 1 commit intoeProsima:masterfrom
PavelGuzenfeld:fix/volatile-reader-init-loop

Conversation

@PavelGuzenfeld
Copy link
Copy Markdown

Summary

Fixes #6338

When a late-joining VOLATILE DataReader initializes against a running DataWriter using data-sharing, init_shared_segment() could spin forever. The fast-forward loop condition used || (OR):

while (ch.sequenceNumber != SequenceNumber_t::unknown() || next_payload_ != current_end)

This kept iterating even when get_next_unread_payload returned unknown — as long as next_payload_ hadn't caught up with a concurrently advancing writer. One CPU core goes to 100%, and discovery threads block behind the PDP mutex.

Fix: change || to &&. The loop should only continue when there IS a valid unread payload AND we haven't reached the end.

Test plan

  • TopicPayloadPoolTests: 2563/2563 pass (ASan + TSan)
  • WaitSetImplTests: 3/3 pass (ASan + TSan)
  • Build clean

Signed-off-by: Pavel Guzenfeld me@pavelguzenfeld.com

When a late-joining VOLATILE DataReader initializes against a running
DataWriter using data-sharing, init_shared_segment() could spin forever
in the fast-forward loop. The loop condition used || (OR) which kept
iterating even when get_next_unread_payload returned unknown — as long
as next_payload_ had not caught up with a concurrently advancing writer.

Fix: change the condition from || to && (AND). The loop should only
continue advancing when there IS a valid unread payload AND we haven't
reached the current end position. When no more payloads are available
(unknown sequence number), the reader is caught up and should stop.

Fixes eProsima#6338

Signed-off-by: Pavel Guzenfeld <me@pavelguzenfeld.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data-sharing VOLATILE DataReader can loop forever in ReaderPool::init_shared_segment()

1 participant