Skip to content

Release change while authentication fails#5935

Merged
MiguelCompany merged 9 commits intoeProsima:masterfrom
Barry-Xu-2018:fix-bug-on-release-change-after-auth-fail
Sep 10, 2025
Merged

Release change while authentication fails#5935
MiguelCompany merged 9 commits intoeProsima:masterfrom
Barry-Xu-2018:fix-bug-on-release-change-after-auth-fail

Conversation

@Barry-Xu-2018
Copy link
Copy Markdown
Contributor

@Barry-Xu-2018 Barry-Xu-2018 commented Jul 15, 2025

Description

Address #5934

particiapant_stateless_message_writer_history should be properly freed when authentication fails.

@Mergifyio backport 3.3.x 3.2.x 2.14.x

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • Any new configuration API has an equivalent XML API (with the corresponding XSD extension)
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • N/A New feature has been documented/Current behavior is correctly described in the documentation.
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

@Mario-DL
Copy link
Copy Markdown
Contributor

Mario-DL commented Jul 31, 2025

@Barry-Xu-2018 thanks for the investigation and the fix, leaving a regression test

@Mario-DL Mario-DL marked this pull request as ready for review July 31, 2025 10:01
@Mario-DL Mario-DL requested review from MiguelCompany and removed request for MiguelCompany July 31, 2025 10:01
@MiguelCompany MiguelCompany modified the milestones: v3.3.1, v3.4.0 Jul 31, 2025
@Mario-DL
Copy link
Copy Markdown
Contributor

For the shake of completeness.
Even with the fix, we should bear in mind that the history of the writer could potentially be full depending on the configuration of the handshake properties i.e having more than 100 requests ongoing without having failed in any of them yet.

Barry-Xu-2018 and others added 5 commits July 31, 2025 12:27
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
@Mario-DL Mario-DL force-pushed the fix-bug-on-release-change-after-auth-fail branch from 49773ce to 5818698 Compare July 31, 2025 10:27
MiguelCompany
MiguelCompany previously approved these changes Jul 31, 2025
@Mario-DL Mario-DL requested review from MiguelCompany and removed request for MiguelCompany July 31, 2025 10:29
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
@MiguelCompany MiguelCompany self-requested a review July 31, 2025 13:45
MiguelCompany
MiguelCompany previously approved these changes Jul 31, 2025
@MiguelCompany MiguelCompany requested review from richiprosima and removed request for richiprosima August 26, 2025 05:29
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 26, 2025

🧪 CI Insights

Here's what we observed from your CI run for ea9c411.

🟢 All jobs passed!

But CI Insights is watching 👀

@MiguelCompany MiguelCompany requested review from richiprosima and removed request for richiprosima September 2, 2025 08:07
@MiguelCompany
Copy link
Copy Markdown
Member

From this CI error report (#5935 (comment)), I am unable to find detailed error information

The CI run expired. I triggered it again here

@MiguelCompany
Copy link
Copy Markdown
Member

@Barry-Xu-2018 The tests look good to me. I am only worried about the ASAN job.

Reports here

@Barry-Xu-2018
Copy link
Copy Markdown
Contributor Author

@MiguelCompany

@Barry-Xu-2018 The tests look good to me. I am only worried about the ASAN job.

Reports here

I checked the contents of the Report, but the failed tests listed there are not related to ASAN.
I can find the ASAN failed tests on the ASAN job page.
image
test_report_fastdds-sanitizers-ci_tsan_fastdds_test

I investigated the data race issues from before and found that they are all related to the following code.

send_to_fixed_locators() and mark_all_readers_interested() can be called simultaneously in two threads. However, in send_to_fixed_locators(), access to should_reach_all_destinations_, fixed_locators_, and interested_readers_ are not protected by a mutex, which leads to a data race.

bool PDPStatelessWriter::send_to_fixed_locators(
const std::vector<eprosima::fastdds::rtps::NetworkBuffer>& buffers,
const uint32_t& total_bytes,
std::chrono::steady_clock::time_point& max_blocking_time_point) const
{
bool ret = true;
if (should_reach_all_destinations_)
{
ret = initial_peers_.empty() ||
mp_RTPSParticipant->sendSync(buffers, total_bytes, m_guid,
Locators(initial_peers_.begin()), Locators(initial_peers_.end()),
max_blocking_time_point, transport_priority_);
if (ret)
{
fixed_locators_.clear();
should_reach_all_destinations_ = false;
}
}
else
{
interested_readers_.clear();
}
return ret;
}

void PDPStatelessWriter::mark_all_readers_interested()
{
std::lock_guard<RecursiveTimedMutex> guard(mp_mutex);
should_reach_all_destinations_ = true;
interested_readers_.clear();
fixed_locators_.clear();
fixed_locators_.push_back(initial_peers_);
reader_data_filter(nullptr);
}

This issue doesn't seem to have been introduced by this PR.

BTW,Could you guide me on running ASAN check in a local environment?

@MiguelCompany
Copy link
Copy Markdown
Member

@Barry-Xu-2018 I was referring to ASAN, not TSAN.

For the new test added, it reports the following:

=================================================================
==37706==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1536 byte(s) in 24 object(s) allocated from:
    #0 0x7f38d6eb61e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7f38d5479588 in eprosima::fastdds::rtps::security::PKIDH::begin_handshake_reply(eprosima::fastdds::rtps::security::Handle**, eprosima::fastdds::rtps::DataHolder**, eprosima::fastdds::rtps::DataHolder&amp;&amp;, eprosima::fastdds::rtps::security::Handle&amp;, eprosima::fastdds::rtps::security::Handle const&amp;, eprosima::fastdds::rtps::CDRMessage_t const&amp;, eprosima::fastdds::rtps::security::SecurityException&amp;) /home/runner/work/Fast-DDS/Fast-DDS/src/fastdds/src/cpp/security/authentication/PKIDH.cpp:1698

Could you guide me on running ASAN check in a local environment?
Use CMake args -DSANITIZER=Address -DCMAKE_BUILD_TYPE=Debug when building fastdds

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
@Barry-Xu-2018
Copy link
Copy Markdown
Contributor Author

@MiguelCompany

I have identified the cause of the memory leak.
Please review this fix 2895379

@MiguelCompany MiguelCompany self-requested a review September 4, 2025 09:19
Copy link
Copy Markdown
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with green CI.
Thank you @Barry-Xu-2018 !

@MiguelCompany MiguelCompany merged commit db64a12 into eProsima:master Sep 10, 2025
37 of 42 checks passed
@MiguelCompany
Copy link
Copy Markdown
Member

@Mergifyio backport 3.3.x 3.2.x 2.14.x

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 10, 2025

backport 3.3.x 3.2.x 2.14.x

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Sep 10, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
emiliocuestaf pushed a commit that referenced this pull request Sep 29, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
MiguelCompany pushed a commit that referenced this pull request Oct 7, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
MiguelCompany pushed a commit that referenced this pull request Oct 7, 2025
* Release change while authentication fails



* Fix uncrustify error



* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods



* Refs #23431: Add regression test



* Refs #23431: Apply Miguel's suggestions



* Refs #23431: Fix windows compilation



* Refs #23431: Uncrustify



* Fix a memory leak on handshake handle



* Fix an Uncrustify error



---------




(cherry picked from commit db64a12)

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Barry Xu <barry.xu@sony.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
emiliocuestaf pushed a commit that referenced this pull request Oct 27, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
MiguelCompany pushed a commit that referenced this pull request Oct 28, 2025
* Release change while authentication fails (#5935)

* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)

* Fix error in decprecated tests

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* Fix backport issues in blackbox tests

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* Uncrustify

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
Co-authored-by: Barry Xu <barry.xu@sony.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Emilio Cuesta <emiliocuesta@eprosima.com>
cferreiragonz pushed a commit that referenced this pull request Nov 12, 2025
* Release change while authentication fails

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Add regression test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Apply Miguel's suggestions

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Fix windows compilation

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #23431: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Fix a memory leak on handshake handle

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Fix an Uncrustify error

Signed-off-by: Barry Xu <barry.xu@sony.com>

---------

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit db64a12)
juanlofer-eprosima pushed a commit that referenced this pull request Nov 13, 2025
* Release change while authentication fails



* Fix uncrustify error



* Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods



* Refs #23431: Add regression test



* Refs #23431: Apply Miguel's suggestions



* Refs #23431: Fix windows compilation



* Refs #23431: Uncrustify



* Fix a memory leak on handshake handle



* Fix an Uncrustify error



---------




(cherry picked from commit db64a12)

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Barry Xu <barry.xu@sony.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.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.

In security mode, when the authentication fails, the change for the handshake request is not released.

4 participants