Skip to content

UBSan: undefined behavior in TimedEvent constructor — inf cast to int64_t on every DataWriter creation #6364

@TUPYP7180

Description

@TUPYP7180

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

TimedEvent should accept any positive double interval, including values representing "no deadline" (i.e., effectively infinite). Passing std::numeric_limits<double>::max() as a timer interval should result in an extremely large — but well-defined — timer period, without invoking undefined behavior. The conversion from milliseconds to microseconds should be guarded against floating-point overflow before casting to int64_t.

Current behavior

Every DataWriter creation triggers a UBSan runtime error:

runtime error: inf is outside the range of representable values of type 'long'

DataWriterImpl::configure_deadline_timer_() unconditionally passes DBL_MAX to the TimedEvent constructor. Inside the constructor, DBL_MAX * 1000 overflows to inf, and the subsequent static_cast<int64_t>(inf) is undefined behavior per C++17.

Steps to reproduce

  1. Build Fast-DDS v3.5.0 with -fsanitize=undefined (UBSan)
  2. Start a DomainParticipant and Publisher
  3. Create any DataWriter with default QoS — the UBSan error fires immediately during DataWriterImpl::enable()

Fast DDS version/commit

v3.5.0 (tag v3.5.0, branch master)
Fast-CDR v2.3.5

Platform/Architecture

Ubuntu Focal 20.04 amd64

Transport layer

UDPv4

Additional context

No response

XML configuration file

Relevant log output

Network traffic capture

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssue pending classification

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions