Repository navigation
Description
Is there an already existing issue for this?
- I have searched the existing issues
Expected behavior
When a reliable DataReader receives a GAP covering a sample whose fragments it is still
reassembling, the partial sample is discarded and later take() calls keep working.
Current behavior
On an unkeyed topic the partial sample stays referenced from the DataReaderHistory instance
after it has been released, and the next take() never returns. It holds the reader mutex, so
every receive thread that dispatches to that reader blocks behind it, and the whole participant
stops receiving.
Sequence, from uprobes on 2.14.6 (ros-jazzy-fastrtps):
- The first DATA_FRAG of a large sample arrives.
StatefulReader::processDataFragMsgcreates the
change andchange_received→DataReaderHistory::received_change. For an unkeyed topic
compute_key_for_change_fn_returns true even though the change is not fully assembled, so it is
added to the history and to the instance'scache_changes(add_to_instance). - The writer (KEEP_LAST 1) replaces that sample before the reader acks it and sends a GAP.
StatefulReader::processGapMsgfinds the partial change withfindCacheInFragmentedProcessand
removes it withmp_history->History::remove_change_nts(ret_iterator)("we call the History
version to avoid callbacks"). That bypassesDataReaderHistory::remove_change_nts, which is
what removes it from the instance, and releases the change (payload length 0).ReadTakeCommand::add_instancereaches the released change, deserialization fails
(NotEnoughMemoryExceptioninread_encapsulation), and it calls
history_.remove_change_sub(change, it).find_change_ntscannot find it, so it returns false
without advancingit, and the loopcontinues on the same element forever.
Stack of the releasing call (receive thread):
CacheChangePool::release_cache(CacheChange_t*)
History::remove_change_nts(const_iterator, bool)
StatefulReader::processGapMsg(...)
MessageReceiver::proc_Submsg_Gap(...)
MessageReceiver::processCDRMsg(...)
ReceiverResource::OnDataReceived(...)
SharedMemChannelResource ... receive thread
Spinning thread: DataReaderImpl::take → read_or_take → TypeSupport::deserialize (throws) →
DataReaderHistory::remove_change_sub(change, it) returns false, repeatedly (millions of times/s).
The same code is in 2.14.x HEAD (StatefulReader.cpp, processGapMsg) and in master
(process_gap_msg's remove_fn).
Steps to reproduce
- Writer: reliable, KEEP_LAST 1, unkeyed type, samples far above the fragment size (we hit it with
a 29.5 MBsensor_msgs/PointCloud2at ~20 Hz over SHM; any size > 64 KB fragments). - Reader: reliable, KEEP_LAST 1, in another process, slow enough to fall one sample behind
(CPU-starved). - Within seconds to minutes a GAP lands mid-reassembly and the reader's process freezes.
A best-effort reader is unaffected (it never processes GAPs).
Fast DDS version/commit
2.14.6 (ROS 2 Jazzy binaries); code unchanged in 2.14.x HEAD and master.
Platform/Architecture
Ubuntu Noble 24.04 amd64
Transport layer
Shared Memory Transport (SHM) (also UDPv4 in the participant)
Additional context
Suggested fixes: remove the change through DataReaderHistory (so the instance is cleaned) in the
GAP path, or do not put partially assembled changes into an unkeyed instance until
completed_change, as is already done for keyed topics. Separately, ReadTakeCommand::add_instance
could advance it when remove_change_sub fails, so a corrupted entry costs one sample instead of
the participant.
Activity