From 6ce60a0de5ec5c28c06ecbcba0b7f0e1958a382d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 6 Oct 2016 16:19:12 +0900 Subject: [PATCH] eo: Fix deadlock in efl_parent_set If the object is shared and the given parent is invalid (eg. deleted) then we will deadlock later. This also adds a test case with it. --- src/lib/eo/eo_base_class.c | 4 ++++ src/tests/eo/suite/eo_test_general.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index d6db732fef..e5d9c915a8 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -582,13 +582,17 @@ _efl_object_parent_set(Eo *obj, Efl_Object_Data *pd, Eo *parent_id) EO_OBJ_DONE(obj); return; + err_parent: ERR("New parent %p for object %p is not a valid Eo object.", parent_id, obj); + EO_OBJ_DONE(obj); return; + err_impossible: ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.", pd->parent, obj); + EO_OBJ_DONE(obj); } EOLIAN static Eo * diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index e08d69699a..b0f1bcd4e1 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -1371,6 +1371,7 @@ thr1(void *data, Eina_Thread t EINA_UNUSED) { Data *d = data; Efl_Id_Domain dom; + Eo *objs2; fail_if(efl_domain_switch(EFL_ID_DOMAIN_THREAD) != EINA_TRUE); fail_if(efl_domain_get() != EFL_ID_DOMAIN_THREAD); @@ -1381,6 +1382,13 @@ thr1(void *data, Eina_Thread t EINA_UNUSED) printf("VERIFY finalized_get()\n"); fail_if(!efl_finalized_get(d->objs)); + printf("VERIFY parent_set(invalid)\n"); + efl_domain_current_push(EFL_ID_DOMAIN_SHARED); + objs2 = efl_add(DOMAIN_CLASS, NULL); + efl_domain_current_pop(); + efl_del(objs2); + efl_parent_set(d->objs, objs2); + printf("SET ON LOCAL\n"); domain_a_set(obj, 1234); fail_if(domain_a_get(obj) != 1234);