Skip to content

fix(agnocastlib): avoid self-deadlock in Subscription destructor - #1689

Open
bdm-k wants to merge 3 commits into
mainfrom
bdm-k/frank-trout
Open

bdm-k wants to merge 3 commits into
mainfrom
bdm-k/frank-trout

Conversation

@bdm-k

@bdm-k bdm-k commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When a subscription is destroyed, its entry in id2_callback_info was erased while holding id2_callback_info_mtx. If the stored CallbackInfo happened to own the last reference to another subscription (for example, a Client captured by a relayed service callback), destroying that entry under the lock would run the nested subscription destructor, which re-acquires the same mutex on the same thread and deadlocks.

This change moves the CallbackInfo entry out under the lock but defers its destruction until after the lock is released, breaking the self-deadlock.

A regression test in test_agnocast_subscription.cpp constructs an outer subscription whose callback captures an inner subscription and asserts that resetting the outer does not deadlock and that the inner is destroyed.

Related links

closes #1687

How was this PR tested?

  • bash scripts/test/e2e_test_1to1.bash (required)
  • bash scripts/test/e2e_test_2to2.bash (required)
  • bash scripts/test/run_requires_kernel_module_tests.bash (required)
  • sample application
  • Autoware

Notes for reviewers

Post-merge checklist

  • Reflect the changes in agnocast_doc after merging (if documentation needs updating)

Signed-off-by: bdm-k <kokusyunn@gmail.com>
@bdm-k bdm-k added the need-patch-update Bug fixes and other changes - requires PATCH version update label Nov 2, 2026
bdm-k added 2 commits November 2, 2026 19:47
Signed-off-by: bdm-k <kokusyunn@gmail.com>
Signed-off-by: bdm-k <kokusyunn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-patch-update Bug fixes and other changes - requires PATCH version update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-deadlock in ~Subscription when a callback owns the last reference to another Subscription

1 participant