Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Segfault in page_flip_handler after fb changes #2634

Closed
kennylevinsen opened this issue Jan 10, 2021 · 0 comments
Closed

Segfault in page_flip_handler after fb changes #2634

kennylevinsen opened this issue Jan 10, 2021 · 0 comments

Comments

@kennylevinsen
Copy link
Member

Regression from #2568, which converts fb struct fields to pointers. Caused by having an output disabled on startup, which happens when I start sway with my laptop lid closed.

As current_fb can now be NULL, we get a segfault with a null pointer dereference if the fbs are not set up.

Core was generated by `sway -d --config /etc/greetd/sway-config'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fe3e47eea74 in page_flip_handler (fd=<optimized out>, seq=901, tv_sec=33, tv_usec=778636, crtc_id=<optimized out>, data=0x556b9fd8e800)
    at ../backend/drm/drm.c:1487
1487            if (!drm->parent && plane->current_fb->wlr_buf &&
[Current thread is 1 (Thread 0x7fe3e3c93900 (LWP 2033))]
(gdb) bt full
#0  0x00007fe3e47eea74 in page_flip_handler (fd=<optimized out>, seq=901, tv_sec=33, tv_usec=778636, crtc_id=<optimized out>, data=0x556b9fd8e800)
    at ../backend/drm/drm.c:1487
        found = true
        conn = 0x556ba0d00170
        plane = 0x556b9fd8d6b0
        present_flags = 7
        present_time = {tv_sec = 93920754016969, tv_nsec = 2}
        present_event = {output = 0x556ba12e22c9, commit_seq = 1622, when = 0x7ffd00000019, seq = 3833208610, refresh = 32739, flags = 25}
#1  0x00007fe3e3e8c487 in drmHandleEvent () at /usr/lib/libdrm.so.2
#2  0x00007fe3e47f1206 in handle_drm_event (fd=<optimized out>, mask=<optimized out>, data=<optimized out>) at ../backend/drm/drm.c:1518
        event = {version = 3, vblank_handler = 0x0, page_flip_handler = 0x0, page_flip_handler2 = 0x7fe3e47ee840 <page_flip_handler>, sequence_handler = 0x0}
#3  0x00007fe3e4883faa in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
#4  0x00007fe3e48824e7 in wl_display_run () at /usr/lib/libwayland-server.so.0
#5  0x0000556b9e801302 in server_run (server=<optimized out>) at ../sway-pr-git/sway/server.c:247
#6  0x0000556b9e7f5633 in main (argc=4, argv=0x7ffd98667fc8) at ../sway-pr-git/sway/main.c:431
        verbose = 0
        debug = 1
        validate = 0
        allow_unsupported_gpu = 0
        long_options = 
            {{name = 0x556b9e848464 "help", has_arg = 0, flag = 0x0, val = 104}, {name = 0x556b9e84bd89 "config", has_arg = 1, flag = 0x0, val = 99}, {name = 0x556b9e848469 "validate", has_arg = 0, flag = 0x0, val = 67}, {name = 0x556b9e848472 "debug", has_arg = 0, flag = 0x0, val = 100}, {name = 0x556b9e8483c8 "version", has_arg = 0, flag = 0x0, val = 118}, {name = 0x556b9e8474b1 "verbose", has_arg = 0, flag = 0x0, val = 86}, {name = 0x556b9e848478 "get-socketpath", has_arg = 0, flag = 0x0, val = 112}, {name = 0x556b9e848487 "unsupported-gpu", has_arg = 0, flag = 0x0, val = 117}, {name = 0x556b9e848497 "my-next-gpu-wont-be-nvidia", has_arg = 0, flag = 0x0, val = 117}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}
        config_path = 0x556b9fd7bed0 "/etc/greetd/sway-config"
        usage = 0x556b9e848808 "Usage: sway [options] [command]\n\n  -h, --help", ' ' <repeats 13 times>, "Show help message and quit.\n  -c, --config <config>  Specify a config file.\n  -C, --validate         Check the validity of the config file, th"...
        c = <optimized out>
(gdb) list
1482                    WLR_OUTPUT_PRESENT_HW_CLOCK | WLR_OUTPUT_PRESENT_HW_COMPLETION;
1483            /* Don't report ZERO_COPY in multi-gpu situations, because we had to copy
1484             * data between the GPUs, even if we were using the direct scanout
1485             * interface.
1486             */
1487            if (!drm->parent && plane->current_fb->wlr_buf &&
1488                            wlr_client_buffer_get(plane->current_fb->wlr_buf)) {
1489                    present_flags |= WLR_OUTPUT_PRESENT_ZERO_COPY;
1490            }
1491
(gdb) p *plane
$1 = {type = 1, id = 31, surf = {renderer = 0x556b9fd8e938, width = 3840, height = 2160, swapchain = 0x556ba0cfef20, back_buffer = 0x0}, mgpu_surf = {renderer = 0x0, 
    width = 0, height = 0, swapchain = 0x0, back_buffer = 0x0}, pending_fb = 0x0, queued_fb = 0x0, current_fb = 0x0, formats = {len = 16, cap = 16, 
    formats = 0x556b9fd8d830}, cursor_enabled = false, cursor_hotspot_x = 0, cursor_hotspot_y = 0, props = {{type = 8, rotation = 33, in_formats = 30, src_x = 9, 
      src_y = 10, src_w = 11, src_h = 12, crtc_x = 13, crtc_y = 14, crtc_w = 15, crtc_h = 16, fb_id = 17, crtc_id = 20}, props = {8, 33, 30, 9, 10, 11, 12, 13, 14, 15, 16, 
      17, 20}}}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants