Skip to content

Endpoint matching deferred on TypeLookup never completes if the reply is not received (no timeout/retry), causing permanent one-directional match loss #6594

Open

Description

@brsbilgin

Environment

  • Fast DDS 3.6.2 (ros-lyrical-fastdds 3.6.2)
  • rmw_fastrtps_cpp 9.4.10
  • ROS 2 Lyrical, Ubuntu 26.04 (WSL2), single host
  • Reproduced with two participant profiles:
    • UDPv4 (loopback only) + SHM, useBuiltinTransports=false
    • UDPv4 only (loopback)
  • Default type propagation (property fastdds.type_propagation not set, i.e. enabled)

Expected behavior

A writer and a reader of the same topic/type in two processes on the same host match on both sides and data flows, regardless of when each process registers the type locally, and regardless of other (possibly short-lived) participants that announced endpoints of the same type earlier.

Actual behavior

In some sessions, a reader never matches a remote writer for the lifetime of the process (or the other way round):

  • the remote side has matched: the writer reports a matched subscription, a service client reports the server as available;
  • the local side never matches: get_publisher_count() stays 0 and no sample is ever delivered;
  • re-creating the local reader does not help (the stuck item is the remote writer's proxy in the local participant);
  • the transport does not matter (same result with SHM+UDP and with UDP only).

On a large system we also see the replying side unable to send TypeLookup replies:

[TYPELOOKUP_SERVICE Warning] Error sending reply. -> Function send
[RTPS_WRITER Warning] Problem reserving cache from pool
[RTPS_HISTORY Warning] Maximum number of allowed reserved caches reached

Two runs of the same launch (about 30 participants, one of them a large component container with ~15 nodes) produced 586 and 817 Error sending reply warnings in that container. With fastdds.type_propagation = disabled there were 0 such warnings and the match losses disappeared.

Root cause analysis (v3.6.2)

  1. src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp:
    • On a remote DATA(w) carrying TypeInformation, EDPSimplePUBListener::add_writer_from_change calls typelookup_manager->async_get_type(...) (line 143). For DATA(r), EDPSimpleSUBListener::add_reader_from_change does the same (line 289).
    • The proxy is only added and paired inside after_typelookup_callback (lines 87 and 232).
  2. src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp, check_type_identifier_received (line 368):
    • If the type identifier is not known locally (line 384), a getTypeDependencies request is sent to the announcing participant, and the proxy plus callback are stored keyed by the type identifier.
    • A later endpoint with the same type identifier, from any participant, is appended to the same entry without sending a new request (lines 397–402).
    • The request is sent before the request id and the callbacks are recorded (lines 406–417).
  3. The pending entry is only resolved in TypeLookupReplyListener::process_reply (TypeLookupReplyListener.cpp, line 87), when a reply matching an outstanding request id arrives (line 107). As a result:
    • There is no timeout and no retry.
    • TypeLookupManager::remove_remote_endpoints (line 228) does not notify or re-request pending entries whose type server was the removed participant.
    • Registering the type locally later (creating a local endpoint of that type) does not re-evaluate pending entries.
    • In check_get_types_reply (line 155), when registering a remote type fails ("Error registering remote type.", lines 174–175 and 214), notify_callbacks is never called.
    • On the replying side, the TypeLookup reply writer history is capped (hatt.maximumReservedCaches = 1000, line 556). When it is exhausted, TypeLookupManager::send logs "Error sending reply." (line 727) and the reply is dropped.
  4. Consequently any endpoint queued behind such an entry is never added to the local participant database, and the match is lost permanently in one direction only. The remote side already knows the type, so it pairs immediately.

Minimal reproducer (rclpy, no simulator)

The scenario runs three processes:

  1. A subscriber process A starts but does not yet create an endpoint of type T (nav_msgs/msg/Path).
  2. Process K creates a T publisher and is SIGKILLed immediately, so A's TypeLookup request to K is never answered.
  3. Process U creates a T publisher and publishes at 10 Hz.
  4. A creates its T subscription and counts samples for 6 s.

Save as repro.py:

import os, signal, subprocess, sys, tempfile, time

TOPIC = 'tl_repro'


def msg_type():
    from nav_msgs.msg import Path  # type with dependencies (Header, PoseStamped[])
    return Path


def wait_file(path, timeout):
    end = time.monotonic() + timeout
    while not os.path.exists(path):
        if time.monotonic() > end:
            return False
        time.sleep(0.02)
    return True


def publisher(workdir, die):
    import rclpy
    rclpy.init()
    node = rclpy.create_node('tl_pub_' + ('short' if die else 'long'))
    T = msg_type()
    pub = node.create_publisher(T, TOPIC, 10)
    if die:
        time.sleep(0.0)                     # let the announcement go out
        os.kill(os.getpid(), signal.SIGKILL)  # die before answering TypeLookup
    msg = T()
    end = time.monotonic() + 30
    while time.monotonic() < end and not os.path.exists(os.path.join(workdir, 'stop')):
        pub.publish(msg)
        with open(os.path.join(workdir, 'pub_matched'), 'w') as f:
            f.write(str(pub.get_subscription_count()))
        rclpy.spin_once(node, timeout_sec=0.1)
    os._exit(0)


def subscriber(workdir):
    import rclpy
    rclpy.init()
    node = rclpy.create_node('tl_sub')     # type T NOT registered yet
    open(os.path.join(workdir, 'sub_ready'), 'w').close()
    wait_file(os.path.join(workdir, 'sub_create'), 60)
    got = [0]
    sub = node.create_subscription(msg_type(), TOPIC,
                                   lambda m: got.__setitem__(0, got[0] + 1), 10)
    end = time.monotonic() + 6.0
    while time.monotonic() < end:
        rclpy.spin_once(node, timeout_sec=0.05)
    with open(os.path.join(workdir, 'result'), 'w') as f:
        f.write(f'{got[0]} {sub.get_publisher_count()}')
    os._exit(0)


def one_round():
    workdir = tempfile.mkdtemp(prefix='tl_repro_')
    me = [sys.executable, os.path.abspath(__file__)]
    a = subprocess.Popen(me + ['sub', workdir])
    wait_file(os.path.join(workdir, 'sub_ready'), 30)
    time.sleep(1.5)
    subprocess.Popen(me + ['pub', workdir, '1']).wait()     # short-lived K
    time.sleep(0.5)
    u = subprocess.Popen(me + ['pub', workdir, '0'])        # long-lived U
    time.sleep(2.5)
    open(os.path.join(workdir, 'sub_create'), 'w').close()
    a.wait(timeout=60)
    received, sub_matched = open(os.path.join(workdir, 'result')).read().split()
    pub_matched = open(os.path.join(workdir, 'pub_matched')).read()
    open(os.path.join(workdir, 'stop'), 'w').close()
    u.wait(timeout=10)
    return int(received), int(sub_matched), int(pub_matched)


if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == 'pub':
        publisher(sys.argv[2], sys.argv[3] == '1')
    elif len(sys.argv) > 1 and sys.argv[1] == 'sub':
        subscriber(sys.argv[2])
    else:
        rounds = int(sys.argv[1]) if len(sys.argv) > 1 else 5
        lost = 0
        for i in range(rounds):
            received, sub_m, pub_m = one_round()
            lost += received == 0
            print(f'round {i}: received={received} subscriber_matched={sub_m} '
                  f'publisher_matched={pub_m} {"LOST" if received == 0 else "ok"}', flush=True)
        print(f'lost {lost}/{rounds}')

Run it:

source /opt/ros/lyrical/setup.bash
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp ROS_DOMAIN_ID=42
python3 repro.py 5

Observed output with default type propagation and builtin transports (no XML profile):

round 0: received=0 subscriber_matched=0 publisher_matched=1 LOST
round 1: received=0 subscriber_matched=0 publisher_matched=1 LOST
round 2: received=0 subscriber_matched=0 publisher_matched=1 LOST
round 3: received=51 subscriber_matched=1 publisher_matched=1 ok
round 4: received=0 subscriber_matched=0 publisher_matched=1 LOST
lost 4/5

With the workaround below, every round reports received≈60 ... ok and lost 0/5. There subscriber_matched=2, because the killed publisher stays matched until its lease expires.

Measured: 13/13 rounds permanently lost with default type propagation (8/8 with UDP+SHM, 5/5 with UDP only), and 0/15 with fastdds.type_propagation = disabled. Under heavy CPU load the loss rate drops to about 50%, because K sometimes manages to reply before it dies.

Waiting longer (tens of seconds) or re-creating the subscription does not recover the match.

A variant without any dying process is also affected, but rarely. One long-lived publisher process creates publishers for 200 distinct message types; the subscriber process creates matching subscriptions 4 s later. 2 of 52 rounds had one type permanently unmatched on the subscriber side, and 0 of 40 rounds with type propagation disabled.

Workaround

Disable type propagation in the participant profile; matching then falls back to the type name:

<?xml version="1.0" encoding="UTF-8"?>
<dds xmlns="http://www.eprosima.com">
  <profiles>
    <participant profile_name="no_type_propagation" is_default_profile="true">
      <rtps>
        <propertiesPolicy>
          <properties>
            <property>
              <name>fastdds.type_propagation</name>
              <value>disabled</value>
            </property>
          </properties>
        </propertiesPolicy>
      </rtps>
    </participant>
  </profiles>
</dds>
export FASTDDS_DEFAULT_PROFILES_FILE=$PWD/no_type_propagation.xml
python3 repro.py 5   # lost 0/5

Participants with this profile still interoperate with participants that use default type propagation, in both directions; this was checked for pub/sub and for services.

Suggested fixes

  • Add a timeout and retry for pending TypeLookup requests. On final failure, notify the callbacks with an error, so that pairing falls back to the type-name matching path that after_typelookup_callback already implements for RETCODE_NO_DATA.
  • When a participant is removed (remove_remote_endpoints), re-send pending requests whose type server was that participant to another announcer of the same type, or fail them as above.
  • When a type becomes known locally (local registration, or a reply to another request), resolve pending entries for that type identifier.
  • Call notify_callbacks in every error branch of check_get_types_reply.
  • Record the request id and the callbacks before sending the request.
  • Do not drop replies silently when the reply writer history is full. Options: KEEP_LAST semantics, removing acknowledged replies, or a configurable limit. At least log the failure on the requesting side.

Activity

  1. cferreiragonz commented on Nov 12, 2026

    @cferreiragonz
    Contributor

    Hi @brsbilgin! Thanks for your contribution. We have solved several errors related with TypeLookup along other related CVEs in the same commit: 3b49667.

    Could you please verify if this issue has been solved after these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions