Bug 51398

Summary: [bug] Weston crash when execute "ls" instantly followed "ctrl+shift+c"
Product: Wayland Reporter: ZhaoShengyan <shengyanx.zhao>
Component: westonAssignee: Wayland bug list <wayland-bugs>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description ZhaoShengyan 2012-06-24 23:55:42 UTC
System Environment:
--------------------------
Arch:     i386
Libdrm:  (master)libdrm-2.4.35-11-ga1d462d2a6f720538eaf1199a94dd27cd04e8a54 
Wayland: (master)67e16be8aa9408d77dc291d9accb238fb9422c94
Mesa:    (master)2f8351a5ac7bb04482eebaa73d967f7527df4d18
Xserver: (master)
xorg-server-1.12.0-232-g8dc70acbf3d82611ac9ec1ec2a52edcc01934850
Xf86_video_intel: 2.19.0-317-g38f06a351fdd35fa5c6136e9a25e034a812a94c2
Cairo:   (master) dbc0efad7e565558a3abf7f69d7675efddc4688d
Cairo_gl: (master) 35e4ffd91cc73fb17c47a12010f515941d6f4d3d
Xkbcommon: (master) 6992de408a890be7bd66f7d829dc84eb9c4b81a6
Weston:  (master) 8fe8d24902a423cb34e2336321a1b5854793b132
Kernel_unstable: (drm-intel-next-queued)
e3f33d46fd917747e966f8e6d25f2940223ad1ee

Bug detailed description:
-----------------------------
Start weston under drm mode, then run weston-terminal. Click weston-terminal and type "ls" and "enter". Nearly at the same time, press "ctrl+shift+c", then weston crash with the following info:
[14:05:20.590]   [000000000804d36a]  --  (./weston)
[14:05:20.590]   [00000000b77d340c]  __kernel_rt_sigreturn  ()
[14:05:20.590]   [0000000008054108]  --  (./weston)
[14:05:20.590]   [00000000080541cf]  --  (./weston)
[14:05:20.590]   [00000000b779122e]  wl_seat_set_selection  (/opt/X11R7/lib/libw                                                                                                 ayland-server.so.0)
[14:05:20.590]   [00000000b77912b5]  --  (/opt/X11R7/lib/libwayland-server.so.0)
[14:05:20.590]   [0000000046a89447]  ffi_call_SYSV  (/usr/lib/libffi.so.5)
[14:05:20.590]   [0000000046a891c0]  ffi_call  (/usr/lib/libffi.so.5)
[14:05:20.590]   [00000000b77930a3]  --  (/opt/X11R7/lib/libwayland-server.so.0)
[14:05:20.590]   [00000000b778ead1]  --  (/opt/X11R7/lib/libwayland-server.so.0)
[14:05:20.590]   [00000000b77913c2]  --  (/opt/X11R7/lib/libwayland-server.so.0)
[14:05:20.590]   [00000000b7791c0a]  wl_event_loop_dispatch  (/opt/X11R7/lib/lib                                                                                                 wayland-server.so.0)
[14:05:20.590]   [00000000b778f9a2]  wl_display_run  (/opt/X11R7/lib/libwayland-                                                                                                 server.so.0)
[14:05:20.590]   [000000000804cd9f]  --  (./weston)
[14:05:20.590]   [00000000466373f3]  __libc_start_main  (/lib/libc.so.6)
[14:05:20.590]   [000000000804cedd]  --  (./weston)

ps. 
1. The time interval of two operations "ls+enter" and "ctrl+shift+c" should within 1 second.
2. This bug can not be reproduced every time, if it doesn't happen, restart weston. The reproduce rate is more or less 70%.

The bug can only be reproduced under drm mode, With X mode, it is normal.

Reproduce steps:
----------------------------
1. Start weston under drm mode.
2. Start weston-terminal.
3. Click weston-terminal.
4. Type "ls" and "Enter" and instantly press "ctrl+shift+c".
Comment 1 ZhaoShengyan 2012-06-25 00:01:26 UTC
Backtraces:
(gdb) bt
#0  clipboard_source_unref (source=0x1) at clipboard.c:57
#1  0x080541cf in clipboard_set_selection (listener=0x81512cc, data=0x8137108)
    at clipboard.c:228
#2  0xb7fbd22e in wl_signal_emit (data=0x8137108, signal=0x8137138)
    at wayland-server.h:166
#3  wl_seat_set_selection (seat=0x8137108, source=0x8169408, serial=29)
    at data-device.c:393
#4  0xb7fbd2b5 in data_device_set_selection (client=0x8162c70,
    resource=0x8208098, source_resource=0x8169408, serial=29)
    at data-device.c:412
#5  0x46a89447 in ffi_call_SYSV () from /usr/lib/libffi.so.5
#6  0x46a891c0 in ffi_call () from /usr/lib/libffi.so.5
#7  0xb7fbf0a3 in wl_closure_invoke (closure=0x81b8d38, target=0x8208098,
    func=0xb7fbd280 <data_device_set_selection>, data=0x8162c70)
    at connection.c:773
#8  0xb7fbaad1 in wl_client_connection_data (fd=43, mask=1, data=0x8162c70)
    at wayland-server.c:253
#9  0xb7fbd3c2 in wl_event_source_fd_dispatch (source=0x8162cc8, ep=0xbfffeee4)
    at event-loop.c:79
#10 0xb7fbdc0a in wl_event_loop_dispatch (loop=0x805d4d0, timeout=-1)
    at event-loop.c:410
#11 0xb7fbb9a2 in wl_display_run (display=0x805d4a0) at wayland-server.c:1045
#12 0x0804cd9f in main (argc=<optimized out>, argv=0xbffff4b4) at compositor.c:3384
Comment 2 ZhaoShengyan 2012-06-26 19:23:36 UTC
With Weston commit e28fd7d5e0175ebda27d05a24a1201722722b6f7, I found I can reproduce the bug under X mode. Also the reproduce rate is 70%. 
FYI.
Comment 3 Kristian Høgsberg 2012-07-01 18:06:37 UTC
Should be fixed by:

commit 340a4343d0755bb918b98743cbe3da9e65433d33
Author: Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
Date:   Sat Jun 30 18:33:34 2012 +0200
    clipboard: initialise clipboard memory after creation

    In case we don't, weston segfault in clipboard_set_selection
    on:

    if (clipboard->source)
                clipboard_source_unref(clipboard->source);
Comment 4 ZhaoShengyan 2012-07-01 19:46:46 UTC
This bug has been closed at Weston commit 340a4343d0755bb918b98743cbe3da9e65433d33
Mark this as RESOLVED AND FIXED.
Comment 5 ZhaoShengyan 2012-07-01 19:47:31 UTC
Mark this as VERIFIED AND FIXED.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.