``` if (toplevel && NtUserIsWindowVisible(hwnd)) wayland_client_surface_attach(client, toplevel); else wayland_client_surface_attach(client, NULL); ``` The above shows up in a few places in winewayland. What ends up happening is that the client surface gets detached, but its pointer is still present in wayland_win_data->client_surface. wayland_surface_reconfigure_subsurface would then try to place itself above the detached client surface without first checking if the client surface has a subsurface (i.e it is attached). Alternatively, we could check if the client surface has a toplevel hwnd set, but this is equivalent and clearer imo. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11104