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

Something is wrong with resource_t in wayland-server++ #73

Open
twaik opened this issue Jan 19, 2023 · 0 comments
Open

Something is wrong with resource_t in wayland-server++ #73

twaik opened this issue Jan 19, 2023 · 0 comments

Comments

@twaik
Copy link

twaik commented Jan 19, 2023

I a writing a backend for Xwayland and something is wrong here.

Code
#include <iostream>
#include <cstdio>
#include <wayland-server.hpp>
#include "wayland-server-protocol.hpp"
#include "xdg-shell-protocol.hpp"

using namespace std;
using namespace wayland::server;

int main()
{
    ::remove("/run/user/1000/wayland-0.lock");
    try {
        cout << "Hello World!" << endl;
        display_t display;
        display.add_socket_auto();
        wl_display_init_shm(display.c_ptr());

        global_compositor_t global_compositor(display);
        global_xdg_wm_base_t global_wm_base(display);
        global_output_t global_output(display);
        global_seat_t global_seat(display);

        global_output.on_bind() = [](const client_t& /*client*/, output_t output) {
            output.geometry(0, 0, 270, 158, output_subpixel::unknown, "weston-x11", "none", output_transform::normal);
            output.scale(1);
            output.mode(3, 1024, 600, 60000);
            output.done();
        };
        global_seat.on_bind() = [](const client_t& /*client*/, seat_t seat) {
            seat.on_get_touch() = [](touch_t /*touch*/) {};
            seat.on_get_keyboard() = [](keyboard_t /*kbd*/) {};
            seat.on_get_pointer() = [](pointer_t pointer) {
                pointer.on_set_cursor() = [](uint32_t /*serial*/, surface_t /*surface*/, int32_t /*hotspot_x*/, int32_t /*hotspot_y*/) {};
            };
            seat.capabilities(seat_capability::pointer | seat_capability::keyboard | seat_capability::touch);
        };

        display.run();
    } catch(const std::exception& ex) {
        std::cout << "Error occured: " << ex.what() << std::endl;
    }
    return 0;
}

Header references are relative to sources because I've built waylandpp with this code to see full stack.

Xwayland version is 22.1.3 (12201003) (old versions have no xdg_shell support).

twaik@twaikPC:~$ WAYLAND_DEBUG=1 ./build-waylandpp-lorie-Desktop-Debug/waylandpp-lorie 
Hello World!
[1997996.676] wl_display@1.get_registry(new id wl_registry@2)
[1997996.738]  -> wl_registry@2.global(1, "wl_shm", 1)
[1997996.760]  -> wl_registry@2.global(2, "wl_compositor", 5)
[1997996.775]  -> wl_registry@2.global(3, "xdg_wm_base", 5)
[1997996.789]  -> wl_registry@2.global(4, "wl_output", 4)
[1997996.805]  -> wl_registry@2.global(5, "wl_seat", 8)
[1997996.821] wl_display@1.sync(new id wl_callback@3)
[1997996.836]  -> wl_callback@3.done(0)
[1997996.850]  -> wl_display@1.delete_id(3)
[1997997.313] wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[1997997.349]  -> wl_shm@4.format(0)
[1997997.361]  -> wl_shm@4.format(1)
[1997997.369] wl_registry@2.bind(2, "wl_compositor", 4, new id [unknown]@5)
[1997997.410] wl_registry@2.bind(3, "xdg_wm_base", 1, new id [unknown]@6)
[1997997.423] wl_registry@2.bind(4, "wl_output", 2, new id [unknown]@7)
[1997997.453]  -> wl_output@7.geometry(0, 0, 270, 158, 0, "weston-x11", "none", 0)
[1997997.490]  -> wl_output@7.scale(1)
[1997997.503]  -> wl_output@7.mode(3, 1024, 600, 60000)
[1997997.516]  -> wl_output@7.done()
[1997997.528] wl_display@1.sync(new id wl_callback@3)
[1997997.539]  -> wl_callback@3.done(0)
[1997997.548]  -> wl_display@1.delete_id(3)
[1998039.809] wl_shm@4.create_pool(new id wl_shm_pool@3, fd 11, 2457600)
[1998039.845] wl_shm_pool@3.create_buffer(new id wl_buffer@8, 0, 1024, 600, 4096, 1)
[1998039.852] wl_shm_pool@3.destroy()
[1998039.856]  -> wl_display@1.delete_id(3)
[1998039.861] wl_compositor@5.create_surface(new id wl_surface@9)
[1998039.884] xdg_wm_base@6.get_xdg_surface(new id xdg_surface@10, wl_surface@9)
[1998039.891] xdg_surface@10.get_toplevel(new id xdg_toplevel@11)
[1998039.896] wl_surface@9.commit()
[1998039.900] wl_compositor@5.create_region(new id wl_region@12)
[1998039.906] wl_region@12.add(0, 0, 1024, 600)
[1998039.913] wl_surface@9.set_opaque_region(wl_region@12)
[1998039.918] wl_region@12.destroy()
[1998055.229] wl_shm@4.create_pool(new id wl_shm_pool@13, fd 11, 1024)
[1998055.252] wl_shm_pool@13.create_buffer(new id wl_buffer@14, 0, 16, 16, 64, 0)
[1998055.258] wl_shm_pool@13.destroy()
[1998055.267]  -> wl_display@1.delete_id(13)
[1998055.271] wl_display@1.get_registry(new id wl_registry@15)
[1998055.275]  -> wl_registry@15.global(1, "wl_shm", 1)
[1998055.279]  -> wl_registry@15.global(2, "wl_compositor", 5)
[1998055.283]  -> wl_registry@15.global(3, "xdg_wm_base", 5)
[1998055.287]  -> wl_registry@15.global(4, "wl_output", 4)
[1998055.291]  -> wl_registry@15.global(5, "wl_seat", 8)
[1998055.300] wl_display@1.sync(new id wl_callback@16)
[1998055.304]  -> wl_callback@16.done(0)
[1998055.306]  -> wl_display@1.delete_id(16)
[1998055.346] wl_registry@2.bind(5, "wl_seat", 5, new id [unknown]@13)
[1998055.358]  -> wl_seat@13.capabilities(7)
[1998055.362] wl_compositor@5.create_surface(new id wl_surface@3)
[1998055.368] wl_display@1.sync(new id wl_callback@16)
[1998055.370]  -> wl_callback@16.done(0)
[1998055.372]  -> wl_display@1.delete_id(16)
[1998056.837] wl_seat@13.get_pointer(new id wl_pointer@17)
[1998056.846] wl_pointer@17.set_cursor(0, nil, 0, 0)
Segmentation fault (core dumped)

if the line starting with pointer.on_set_cursor() is not commented out my app falls with segfault.
For some reason data == null is true in resource_t::set_events.
It looks like there is a problem when resource_t should be empty...

Qt stacktrace screenshot

image

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

No branches or pull requests

1 participant