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

Drag and drop crash when dropping on a target that does not support DND #1570

Closed
aidanharris opened this issue Feb 24, 2019 · 2 comments
Closed

Comments

@aidanharris
Copy link

The title is my best guess at what's going on. In sway when dropping onto a window that does not support DND (tested by dragging a folder from Dolphin into Alacritty) I get a crash. Patching wlroots as follows seems to fix things:

diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c

index 086feb11..2a1cd6f2 100644

--- a/types/data_device/wlr_data_offer.c

+++ b/types/data_device/wlr_data_offer.c

@@ -98,7 +98,7 @@ static void data_offer_handle_receive(struct wl_client *client,

 

 static void data_offer_dnd_finish(struct wlr_data_offer *offer) {

 	struct wlr_data_source *source = offer->source;

-	if (source->actions < 0) {

+	if (source && source->actions < 0) {

 		return;

 	}

 

diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c

index 0ab0d7f7..d2a72898 100644

--- a/types/data_device/wlr_data_source.c

+++ b/types/data_device/wlr_data_source.c

@@ -61,6 +61,8 @@ void wlr_data_source_dnd_drop(struct wlr_data_source *source) {

 }

 

 void wlr_data_source_dnd_finish(struct wlr_data_source *source) {

+	if (source == NULL)

+		return;

 	if (source->impl->dnd_finish) {

 		source->impl->dnd_finish(source);

 	}
[New LWP 21890]

[New LWP 21954]

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib64/libthread_db.so.1".

Core was generated by `sway'.

Program terminated with signal SIGSEGV, Segmentation fault.

#0  data_offer_dnd_finish (offer=offer@entry=0x555919284e60) at ../wlroots-9999/types/data_device/wlr_data_offer.c:101

101		if (source->actions < 0) {

[Current thread is 1 (Thread 0x7ff8915da9c0 (LWP 21890))]



Thread 2 (Thread 0x7ff8906d6700 (LWP 21954)):

#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x555918ca4d28) at ../sysdeps/unix/sysv/linux/futex-internal.h:88

        __ret = -512

        oldtype = 0

        err = <optimized out>

        oldtype = <optimized out>

        err = <optimized out>

        __ret = <optimized out>

        resultvar = <optimized out>

        __arg4 = <optimized out>

        __arg3 = <optimized out>

        __arg2 = <optimized out>

        __arg1 = <optimized out>

        _a4 = <optimized out>

        _a3 = <optimized out>

        _a2 = <optimized out>

        _a1 = <optimized out>

#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x555918ca4cd8, cond=0x555918ca4d00) at pthread_cond_wait.c:502

        spin = 0

        buffer = {__routine = 0x7ff8937b9e30 <__condvar_cleanup_waiting>, __arg = 0x7ff8906d5b00, __canceltype = 0, __prev = 0x0}

        cbuffer = {wseq = 0, cond = 0x555918ca4d00, mutex = 0x555918ca4cd8, private = 0}

        rt = <optimized out>

        err = <optimized out>

        g = 0

        flags = <optimized out>

        g1_start = <optimized out>

        signals = <optimized out>

        result = 0

        wseq = 0

        seq = 0

        private = 0

        maxspin = <optimized out>

        err = <optimized out>

        result = <optimized out>

        wseq = <optimized out>

        g = <optimized out>

        seq = <optimized out>

        flags = <optimized out>

        private = <optimized out>

        signals = <optimized out>

        g1_start = <optimized out>

        spin = <optimized out>

        buffer = <optimized out>

        cbuffer = <optimized out>

        rt = <optimized out>

        s = <optimized out>

#2  __pthread_cond_wait (cond=0x555918ca4d00, mutex=0x555918ca4cd8) at pthread_cond_wait.c:655

No locals.

#3  0x00007ff890c04373 in ?? () from /usr/lib64/dri/i965_dri.so

No symbol table info available.

#4  0x00007ff890c040d7 in ?? () from /usr/lib64/dri/i965_dri.so

No symbol table info available.

#5  0x00007ff8937b3433 in start_thread (arg=<optimized out>) at pthread_create.c:486

        ret = <optimized out>

        pd = <optimized out>

        now = <optimized out>

        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140705551705856, -8205974454620659105, 140721541816718, 140721541816719, 140705551705856, 0, 8209962543312527967, 8209960156223890015}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}

        not_first_call = <optimized out>

#6  0x00007ff8938d52af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

No locals.



Thread 1 (Thread 0x7ff8915da9c0 (LWP 21890)):

#0  data_offer_dnd_finish (offer=offer@entry=0x555919284e60) at ../wlroots-9999/types/data_device/wlr_data_offer.c:101

        source = 0x0

#1  0x00007ff893a55a40 in data_offer_destroy (offer=offer@entry=0x555919284e60) at ../wlroots-9999/types/data_device/wlr_data_offer.c:199

No locals.

#2  0x00007ff893a566da in drag_set_focus (drag=0x555919282b00, surface=0x5559191b3cc0, sx=1549.9885016931967, sy=432.99714110049109) at ../wlroots-9999/types/data_device/wlr_drag.c:41

        client = <optimized out>

        offer = 0x555919284e60

        tmp = 0x555918cf38d0

        resource = <optimized out>

        focus_client = <optimized out>

#3  0x00007ff893a56aa2 in drag_handle_pointer_enter (grab=<optimized out>, surface=<optimized out>, sx=<optimized out>, sy=<optimized out>) at ../wlroots-9999/types/data_device/wlr_drag.c:159

        drag = <optimized out>

#4  0x00007ff893a580c4 in wlr_seat_pointer_notify_enter (wlr_seat=wlr_seat@entry=0x555918cf3860, surface=surface@entry=0x5559191b3cc0, sx=sx@entry=1549.9885016931967, sy=sy@entry=432.99714110049109) at ../wlroots-9999/types/seat/wlr_seat_pointer.c:329

        grab = <optimized out>

#5  0x00005559175b91db in cursor_do_rebase (cursor=cursor@entry=0x555918cf3c30, time_msec=time_msec@entry=19141273, node=node@entry=0x5559191bf460, surface=surface@entry=0x5559191b3cc0, sx=sx@entry=1549.9885016931967, sy=sy@entry=432.99714110049109) at ../sway-9999/sway/input/cursor.c:272

        wlr_seat = 0x555918cf3860

#6  0x00005559175b9383 in cursor_send_pointer_motion (cursor=cursor@entry=0x555918cf3c30, time_msec=19141273, node=0x5559191bf460, surface=0x5559191b3cc0, sx=1549.9885016931967, sy=432.99714110049109) at ../sway-9999/sway/input/cursor.c:404

        seat = 0x555918cf3720

        prev_node = <optimized out>

        drag_icon = <optimized out>

#7  0x00005559175ba54a in handle_cursor_motion (listener=0x555918cf3ca0, data=0x7ffc49832ff0) at ../sway-9999/sway/input/cursor.c:457

        cursor = 0x555918cf3c30

        event = 0x7ffc49832ff0

        dx = -53.579753197978441

        dy = 22.931551980113053

        dx_unaccel = <optimized out>

        dy_unaccel = <optimized out>

        surface = 0x5559191b3cc0

        node = <optimized out>

        sx = 1549.9885016931967

        sy = 432.99714110049109

#8  0x00007ff893a799c6 in wlr_signal_emit_safe (signal=<optimized out>, data=0x7ffc49832ff0) at ../wlroots-9999/util/signal.c:29

        pos = 0x555918cf3ca0

        l = 0x555918cf3ca0

        cursor = {link = {prev = 0x555918cf3ca0, next = 0x7ffc49832f40}, notify = 0x7ff893a79952 <handle_noop>}

        end = {link = {prev = 0x7ffc49832f20, next = 0x555918cf3e98}, notify = 0x7ff893a79952 <handle_noop>}

#9  0x00007ff893a649b2 in handle_pointer_motion (listener=<optimized out>, data=<optimized out>) at ../wlroots-9999/types/wlr_cursor.c:351

        event = <optimized out>

        device = <optimized out>

#10 0x00007ff893a799c6 in wlr_signal_emit_safe (signal=<optimized out>, data=data@entry=0x7ffc49832ff0) at ../wlroots-9999/util/signal.c:29

        pos = 0x55591913d9d0

        l = 0x55591913d9d0

        cursor = {link = {prev = 0x55591913d9d0, next = 0x7ffc49832fb0}, notify = 0x7ff893a79952 <handle_noop>}

        end = {link = {prev = 0x7ffc49832f90, next = 0x5559190bb818}, notify = 0x7ff893a79952 <handle_noop>}

#11 0x00007ff893a4913a in handle_pointer_motion (event=event@entry=0x55591928a300, libinput_dev=libinput_dev@entry=0x555918f00bd0) at ../wlroots-9999/backend/libinput/pointer.c:41

        wlr_dev = 0x5559190bb790

        pevent = 0x55591928a300

        wlr_event = {device = 0x5559190bb790, time_msec = 19141273, delta_x = -53.579753197978441, delta_y = 22.931551980113053, unaccel_dx = -184, unaccel_dy = 78.75}

#12 0x00007ff893a48d51 in handle_libinput_event (backend=backend@entry=0x555918b67e50, event=event@entry=0x55591928a300) at ../wlroots-9999/backend/libinput/events.c:240

        libinput_dev = 0x555918f00bd0

        event_type = LIBINPUT_EVENT_POINTER_MOTION

#13 0x00007ff893a4802f in handle_libinput_readable (fd=<optimized out>, mask=<optimized out>, _backend=0x555918b67e50) at ../wlroots-9999/backend/libinput/backend.c:41

        backend = 0x555918b67e50

        event = 0x55591928a300

#14 0x00007ff893abbdc2 in wl_event_loop_dispatch (loop=0x555918b59ee0, timeout=timeout@entry=-1) at /usr/src/debug/dev-libs/wayland-9999/wayland-9999/src/event-loop.c:641

        ep = {{events = 1, data = {ptr = 0x5559190b0160, fd = 420151648, u32 = 420151648, u64 = 93841160601952}}, {events = 1, data = {ptr = 0x555918b58080, fd = 414548096, u32 = 414548096, u64 = 93841154998400}}, {events = 3303923200, data = {ptr = 0x555931886435, fd = 831022133, u32 = 831022133, u64 = 93841571472437}}, {events = 0, data = {ptr = 0x10, fd = 16, u32 = 16, u64 = 16}}, {events = 421564128, data = {ptr = 0x4983313000005559, fd = 21849, u32 = 21849, u64 = 5297131668946048345}}, {events = 32764, data = {ptr = 0x55591920bef8, fd = 421576440, u32 = 421576440, u64 = 93841162026744}}, {events = 421568232, data = {ptr = 0x4983317000005559, fd = 21849, u32 = 21849, u64 = 5297131943823955289}}, {events = 32764, data = {ptr = 0x7ff893abc3cd <wl_connection_flush+365>, fd = -1817459763, u32 = 2477507533, u64 = 140705606124493}}, {events = 16, data = {ptr = 0x498331a000000000, fd = 0, u32 = 0, u64 = 5297132149982363648}}, {events = 32764, data = {ptr = 0x7ffc49833190, fd = 1233334672, u32 = 1233334672, u64 = 140721541820816}}, {events = 0, data = {ptr = 0x4234, fd = 16948, u32 = 16948, u64 = 16948}}, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 1233334640, data = {ptr = 0x100007ffc, fd = 32764, u32 = 32764, u64 = 4295000060}}, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 421568796, data = {ptr = 0x1000005559, fd = 21849, u32 = 21849, u64 = 68719498585}}, {events = 0, data = {ptr = 0x555919209ee8, fd = 421568232, u32 = 421568232, u64 = 93841162018536}}, {events = 16, data = {ptr = 0x1400000000, fd = 0, u32 = 0, u64 = 85899345920}}, {events = 0, data = {ptr = 0x100000001, fd = 1, u32 = 1, u64 = 4294967297}}, {events = 85, data = {ptr = 0x5559, fd = 21849, u32 = 21849, u64 = 21849}}, {events = 0, data = {ptr = 0x7ffc498333c0, fd = 1233335232, u32 = 1233335232, u64 = 140721541821376}}, {events = 392014523, data = {ptr = 0x1000005559, fd = 21849, u32 = 21849, u64 = 68719498585}}, {events = 48, data = {ptr = 0x7ffc498332a0, fd = 1233334944, u32 = 1233334944, u64 = 140721541821088}}, {events = 1233334752, data = {ptr = 0xc4edde0000007ffc, fd = 32764, u32 = 32764, u64 = 14190242092495699964}}, {events = 831022133, data = {ptr = 0x7ff8915da7d0, fd = -1856133168, u32 = 2438834128, u64 = 140705567451088}}, {events = 418408080, data = {ptr = 0x175dd69500005559, fd = 21849, u32 = 21849, u64 = 1683737771144926553}}, {events = 21849, data = {ptr = 0xd5, fd = 213, u32 = 213, u64 = 213}}, {events = 416228457, data = {ptr = 0x18cfc6c000005559, fd = 21849, u32 = 21849, u64 = 1787866105025418585}}, {events = 21849, data = {ptr = 0x5559190552e0, fd = 419779296, u32 = 419779296, u64 = 93841160229600}}, {events = 3303923200, data = {ptr = 0x18f0ab7031886435, fd = 831022133, u32 = 831022133, u64 = 1797124749676536885}}, {events = 21849, data = {ptr = 0x5559191b0160, fd = 421200224, u32 = 421200224, u64 = 93841161650528}}}

        source = <optimized out>

        i = <optimized out>

        count = <optimized out>

#15 0x00007ff893aba9fa in wl_display_run (display=0x555918b5c900) at /usr/src/debug/dev-libs/wayland-9999/wayland-9999/src/wayland-server.c:1293

No locals.

#16 0x00005559175ab51e in server_run (server=0x5559175f9b60 <server>) at ../sway-9999/sway/server.c:214

No locals.

#17 0x00005559175aad99 in main (argc=1, argv=0x7ffc498333c8) at ../sway-9999/sway/main.c:406

        verbose = 0

        debug = 0

        validate = 0

        allow_unsupported_gpu = 0

        long_options = {{name = 0x5559175dd63c "help", has_arg = 0, flag = 0x0, val = 104}, {name = 0x5559175dc521 "config", has_arg = 1, flag = 0x0, val = 99}, {name = 0x5559175dd641 "validate", has_arg = 0, flag = 0x0, val = 67}, {name = 0x5559175dd64a "debug", has_arg = 0, flag = 0x0, val = 100}, {name = 0x5559175dd650 "version", has_arg = 0, flag = 0x0, val = 118}, {name = 0x5559175dd082 "verbose", has_arg = 0, flag = 0x0, val = 86}, {name = 0x5559175dd658 "get-socketpath", has_arg = 0, flag = 0x0, val = 112}, {name = 0x5559175dd667 "unsupported-gpu", has_arg = 0, flag = 0x0, val = 117}, {name = 0x5559175dd677 "my-next-gpu-wont-be-nvidia", has_arg = 0, flag = 0x0, val = 117}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}

        config_path = 0x0

        usage = 0x5559175dfea8 "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>
@emersion
Copy link
Member

Can you try #1574?

@aidanharris
Copy link
Author

Works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants