Revert two commits as an attempt to avoid crash
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 22 Sep 2022 06:58:47 +0000 (15:58 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 16 Feb 2023 10:22:32 +0000 (19:22 +0900)
This reverts following two commits.

    "wayland-client: Delete pthread_key before iterating thread_data"
    commit c4a2e5dbe2d6d371de814c24b578e9d3196ec971.

    "wayland-client: Destroy all thread data on disconnect"
    commit d5f09227a4d62c48ade0905be13b4645fde02cd0.

And this is the backtrace.

    (gdb)bt full
    0  0xb56937f8 in wl_list_remove (elm=elm@entry=0xa40520) at
    /usr/src/debug/wayland-1.20.0/builddir/../src/wayland-util.c:67
    No locals.
    1  0xb5693a86 in destroy_thread_data (data=0xa40520) at
    /usr/src/debug/wayland-1.20.0/builddir/../src/wayland-client.c:1195
            display = 0x913d80
            thread_data = 0xa40520
            __PRETTY_FUNCTION__ = "destroy_thread_data"
    2  0xb5e1634c in __nptl_deallocate_tsd () at
    /usr/src/debug/glibc-2.30/nptl/pthread_create.c:301
            data = <optimized out>
            inner = <optimized out>
            level2 = 0x9b9731ac
            idx = <optimized out>
            round = 0
            cnt = <optimized out>
            self = 0x9b973120
    3  0xb5e164d4 in start_thread (arg=0x9b973120) at
    /usr/src/debug/glibc-2.30/nptl/pthread_create.c:490
            pd = 0x9b973120
            unwind_buf = {cancel_jmp_buf = {{jmp_buf = {1530611246,
    1967982998, -1684590304, -1552949728, -1552943648, 338, -1552949818, 0,
    -1684590304, -1684591524, 0 <repeats 54 times>}, mask_was_saved = 0}},
    priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0,
    canceltype = 0}}}
            not_first_call = <optimized out>
    4  0xb5f3c988 in __inet_pton_length () at
    /usr/src/debug/glibc-2.30/misc/../sysdeps/unix/sysv/linux/arm/clone.S:73
    No locals.
    5  0x00000000 in ?? ()

Not sure this crash happened because of the patches to be reverted but
let just the leak happen and let's see if crash happen again.

Change-Id: I478fe965ae5b633039b31e103203c733948abda1

src/wayland-client.c

index 12418a6..49e646e 100644 (file)
@@ -1612,7 +1612,7 @@ wl_display_disconnect(struct wl_display *display)
        int pid = -1;
        int tid = -1;
 
-       struct wl_thread_data *thread_data, *th_data_next;
+       struct wl_thread_data *thread_data;
 
        pthread_mutex_lock(&display->mutex);
 
@@ -1621,14 +1621,13 @@ wl_display_disconnect(struct wl_display *display)
        {
                pid = thread_data->pid;
                tid = thread_data->tid;
+               destroy_thread_data(thread_data);
+               thread_data = NULL;
        }
 
        pthread_setspecific(display->thread_data_key, NULL);
        pthread_key_delete(display->thread_data_key);
 
-       wl_list_for_each_safe(thread_data, th_data_next, &display->threads, link)
-               destroy_thread_data(thread_data);
-
        wl_connection_destroy(display->connection);
        wl_map_for_each(&display->objects, free_zombies, NULL);
        wl_map_release(&display->objects);