Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend/rs: server: Fix potential deadlock on object destruction #744

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions wayland-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bugfixes

- backend/rs: server: Fixed potential deadlock on object destruction

## 0.3.5 -- 2024-07-03

#### Additions
Expand Down
5 changes: 5 additions & 0 deletions wayland-backend/src/rs/server_impl/common_poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ impl<D> InnerBackend<D> {
panic!("An object data was returned from a callback not creating any object");
}
}
// dropping the object calls destructors from which users could call into wayland-backend again.
// so lets release and relock the state again, to avoid a deadlock
std::mem::drop(state);
std::mem::drop(object);
state = self.state.lock().unwrap();
}
DispatchAction::Bind { object, client, global, handler } => {
// temporarily unlock the state Mutex while this request is dispatched
Expand Down
4 changes: 4 additions & 0 deletions wayland-backend/src/server_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,12 @@ impl<D> Backend<D> {
}
}

// Workaround: Some versions of rustc throw a `struct is never constructed`-warning here,
// if the `server_system`-feature is enabled, even though the `rs`-module makes use if it.
#[allow(dead_code)]
pub(crate) struct DumbObjectData;

#[allow(dead_code)]
impl<D> ObjectData<D> for DumbObjectData {
#[cfg_attr(coverage, coverage(off))]
fn request(
Expand Down
14 changes: 0 additions & 14 deletions wayland-client/src/event_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,20 +703,6 @@ impl<I: Proxy, U: std::fmt::Debug, State> std::fmt::Debug for QueueProxyData<I,
}
}

struct TemporaryData;

impl ObjectData for TemporaryData {
fn event(
self: Arc<Self>,
_: &Backend,
_: Message<ObjectId, OwnedFd>,
) -> Option<Arc<dyn ObjectData>> {
unreachable!()
}

fn destroyed(&self, _: ObjectId) {}
}

/*
* Dispatch delegation helpers
*/
Expand Down
Loading