e_comp_wl: fix data race issue of kbd.focus 69/324769/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 23 May 2025 12:55:16 +0000 (21:55 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 26 May 2025 07:02:33 +0000 (16:02 +0900)
==================
WARNING: ThreadSanitizer: data race (pid=432)
  Write of size 8 at 0x007fe9102648 by main thread:
    #0 _e_comp_wl_input_thread_focus_in src/bin/server/e_comp_wl.c:2261 (enlightenment+0xb04d8)
    #1 e_comp_wl_feed_focus_in src/bin/server/e_comp_wl.c:2290 (enlightenment+0xb04d8)
    #2 _e_comp_wl_evas_cb_focus_in src/bin/server/e_comp_wl.c:2304 (enlightenment+0xb0620)
    #3 <null> <null> (libevas.so.1+0xccd84)
    #4 <null> <null> (libevas.so.1+0x1144e8)
    #5 e_client_frame_focus_set src/bin/core/e_client.c:6081 (enlightenment+0x58be0)
    #6 _focus_policy_history_update src/bin/windowmgr/e_focus_policy_history.c:1253 (enlightenment+0x180a5c)
    #7 e_focus_update src/bin/windowmgr/e_focus.c:97 (enlightenment+0x17d448)
    #8 e_comp_idler_before src/bin/compmgr/e_comp.c:1503 (enlightenment+0x1cc7c0)
    #9 _e_main_cb_idle_before src/bin/e_main.c:1211 (enlightenment+0x43664)
    #10 _ecore_call_task_cb ../src/lib/ecore/ecore_private.h:470 (libecore.so.1+0x270bc)
    #11 _ecore_factorized_idle_process ../src/lib/ecore/ecore_idler.c:49 (libecore.so.1+0x270bc)
    #12 _ecore_factorized_idle_process ../src/lib/ecore/ecore_idler.c:39 (libecore.so.1+0x270bc)
    #13 __libc_start_main ../csu/libc-start.c:308 (libc.so.6+0x23ff0)

  Previous write of size 8 at 0x007fe9102648 by thread T10:
    #0 _e_input_thread_client_cb_focus_set src/bin/server/e_comp_wl.c:3406 (enlightenment+0xa2b58)
    #1 _pipe_recv_handler src/bin/inputmgr/e_input_backend.c:1232 (enlightenment+0x19f890)
    #2 <null> <null> (libglib-2.0.so.0+0x5d5f0)
    #3 _ecore_direct_worker ../src/lib/ecore/ecore_thread.c:481 (libecore.so.1+0x652d0)

  Location is heap block of size 224 at 0x007fe91025a0 allocated by main thread:
    #0 calloc <null> (libtsan.so.0+0x3859c)
    #1 e_comp_input_init src/bin/inputmgr/e_comp_input.c:14 (enlightenment+0x19a400)
    #2 e_input_init src/bin/inputmgr/e_input.c:162 (enlightenment+0x19b840)
    #3 e_comp_screen_init src/bin/e_comp_screen.c:576 (enlightenment+0x465a8)
    #4 _e_main_screens_init src/bin/e_main.c:1147 (enlightenment+0x40790)
    #5 main src/bin/e_main.c:653 (enlightenment+0x40790)

  Thread T10 'input-thread' (tid=791, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x395f0)
    #1 <null> <null> (libeina.so.1+0x5157c)
    #2 main src/bin/e_main.c:684 (enlightenment+0x42218)

SUMMARY: ThreadSanitizer: data race src/bin/server/e_comp_wl.c:2261 in _e_comp_wl_input_thread_focus_in
==================

Change-Id: I3242cfd7d0263836292c33dcda40bdd8848e5187
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/server/e_comp_wl.c

index eab638537f90cc3042303aa70fe21d8d0ebb34b2..d1f450234c47db0bd3a5a15965e1d469f4c0e163 100644 (file)
@@ -3380,19 +3380,6 @@ _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t p
    _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
 }
 
-static void
-_e_input_thread_client_cb_focus_set(void *data)
-{
-   struct wl_resource *surface = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(data);
-   surface = *(struct wl_resource **)data;
-
-   ICINF("[input thread|%s] surface(%p)", __func__, surface);
-
-   e_comp_input_key->kbd.focus = surface;
-}
-
 static void
 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
 {
@@ -3405,22 +3392,7 @@ _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
           _e_comp_wl_configure_send(ec, 0, 0);
      }
 
-   ICINF("[%s] surface(%p)", __func__, ec->comp_data->surface);
-   e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_set, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
-}
-
-static void
-_e_input_thread_client_cb_focus_unset(void *data)
-{
-   struct wl_resource *surface = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(data);
-   surface = *(struct wl_resource **)data;
-
-   ICINF("[input thread|%s] surface(%p)", __func__, surface);
-
-   if (e_comp_input_key->kbd.focus == surface)
-     e_comp_input_key->kbd.focus = NULL;
+   e_comp_input_key->kbd.focus = ec->comp_data->surface;
 }
 
 static void
@@ -3437,8 +3409,8 @@ _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
 
    _e_comp_wl_focus_check();
 
-   ICINF("[%s] surface(%p)", __func__, ec->comp_data->surface);
-   e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_unset, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
+   if (e_comp_input_key->kbd.focus == ec->comp_data->surface)
+     e_comp_input_key->kbd.focus = NULL;
 }
 
 static void