Smithay / smithay

A smithy for rusty wayland compositors
MIT License
1.9k stars 168 forks source link

xwm memory leak in MapRequest handler #1117

Open luveti opened 1 year ago

luveti commented 1 year ago

I've wrote a GTK4 application (using https://gtk-rs.org) and was testing it in my compositor. I noticed when I close this application, several X11 windows would be left behind.

The GTK4 application maps itself 3 times for some reason, without first unmapping itself. This occurs on the simplest example app.

When I close the app, 2 windows are left behind. I believe I've tracked it down to this code here: https://github.com/Smithay/smithay/blob/master/src/xwayland/xwm/mod.rs#L1357-L1405e

This is not checking if surface.state.lock().unwrap().mapped_onto.is_some(), adding this check fixes the leak. Would this be the correct fix? Or should we be performing anything that's done inside this block https://github.com/Smithay/smithay/blob/master/src/xwayland/xwm/mod.rs#L1536-L1579

Drakulix commented 1 year ago

That surely is an interesting bug.

When I close the app, 2 windows are left behind. I believe I've tracked it down to this code here: https://github.com/Smithay/smithay/blob/master/src/xwayland/xwm/mod.rs#L1357-L1405e

I don't see any other important logic in MapRequest that would be skip by this solution, so I think this is a good approach. Please feel free to make a pull request.