Skip to content

Fix dead lock at session mutex#1199

Open
riebl wants to merge 2 commits into
eclipse-zenoh:mainfrom
riebl:session_dead_lock
Open

Fix dead lock at session mutex#1199
riebl wants to merge 2 commits into
eclipse-zenoh:mainfrom
riebl:session_dead_lock

Conversation

@riebl
Copy link
Copy Markdown

@riebl riebl commented Apr 10, 2026

Description

With LOCAL_PUBLISHER and LOCAL_QUERYABLE enabled, I noticed a deadlock when publishing from a query callback (using zenoh-cpp with zenoh-pico backend).

What does this PR do?

Callbacks are no longer invoked while session mutex is still locked. Instead, the callback function pointer and its argument are stored on stack and invoked as soon as session mutex is unlocked.

Why is this change needed?

Publisher blocks infinitely at session mutex when called from a callback and session mutex is already acquired by call stack.

Related Issues

N/A


🏷️ Label-Based Checklist

No specific label requirements detected.

Current labels: No labels

Add one of these labels to this PR to see relevant checklist items: api-sync, breaking-change, bug, ci, dependencies, documentation, enhancement, new feature, internal

This section updates automatically when labels change.

riebl added 2 commits April 10, 2026 22:53
Signed-off-by: Raphael Riebl <raphael@riebl.net>
Signed-off-by: Raphael Riebl <raphael@riebl.net>
@DenisBiryukov91
Copy link
Copy Markdown
Contributor

It is generally not advised to do any blocking operation (which the publish is) from callbacks, since this starves zenoh-pico background thread - one can use channels if needed for this purpose.
So it is not entirely clear whether the issue needs fixing.

@riebl
Copy link
Copy Markdown
Author

riebl commented Apr 13, 2026

Yes, I also merely schedule the publisher invocation in my callback now. However, it can be a quite unpleasant surprise when switching from zenoh-c to zenoh-pico as backend for zenoh-cpp and suddenly the application is trapped in a deadlock.

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.

2 participants